Skip to content

Commit 89c1b58

Browse files
committed
fix: clean up script issues
Various fixes to the scripts (some things only workded because I was pasting the script into my zsh shell). Scripts now run reliably under bash.
1 parent e3ed3c7 commit 89c1b58

File tree

4 files changed

+162
-56
lines changed

4 files changed

+162
-56
lines changed

regex-assembly/exclude/unix-shell-fps-pl1.ra

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,10 @@
1212
##! `awk@` to `awk~`, this list would not have to be updated.
1313

1414
##! To automatically add exclusions for English words from the sources, run the following:
15-
##! original="$(grep -vE '^(?:#|$)' regex-assembly/exclude/unix-shell-fps-pl1.ra)"
16-
##! upto3="$(grep -vE '^(?:#|$)' regex-assembly/include/unix-shell-upto3.ra)"
17-
##! rest="$(grep -vE '^(?:#|$)' regex-assembly/include/unix-shell-4andup-with-params.ra)"
15+
##! NL=$'\n'
16+
##! original="$(grep -vE '^[#$]' regex-assembly/exclude/unix-shell-fps-pl1.ra)"
17+
##! upto3="$(grep -vE '^[#$]' regex-assembly/include/unix-shell-upto3.ra)"
18+
##! rest="$(grep -vE '^[#$]' regex-assembly/include/unix-shell-4andup-with-params.ra)"
1819
##! english_upto3="$(util/fp-finder/spell.sh -m -e regex-assembly/include/unix-shell-upto3.ra)"
1920
##! # strip suffixes from words so that spell.sh works
2021
##! english_rest="$(util/fp-finder/spell.sh -m -e -s '{{[^}]+}}' regex-assembly/include/unix-shell-4andup-with-params.ra)"
@@ -27,17 +28,17 @@
2728
##! found=0
2829
##! while read -r eword; do
2930
##! if grep -qE "^${eword}(?:[@~]|\{\{.*|$)" <<<"${oword}"; then
30-
##! result="${result}${eword}\n"
31-
##! result="${result}${eword}@\n"
32-
##! result="${result}${eword}~\n"
33-
##! result="${result}${eword}{{space-or-redirect}}\n"
34-
##! result="${result}${eword}{{no-space}}\n"
31+
##! result="${result}${eword}${NL}"
32+
##! result="${result}${eword}@${NL}"
33+
##! result="${result}${eword}~${NL}"
34+
##! result="${result}${eword}{{space-or-redirect}}${NL}"
35+
##! result="${result}${eword}{{no-space}}${NL}"
3536
##! found=1
3637
##! break
3738
##! fi
3839
##! done <<<"${1}"
3940
##! if [ ${found} -eq 0 ]; then
40-
##! result="${result}${oword}\n"
41+
##! result="${result}${oword}${NL}"
4142
##! fi
4243
##! done <<<"${original}"
4344
##! }
@@ -47,11 +48,11 @@
4748
##! fi
4849
##! while read -r eword; do
4950
##! if ! grep -qE "^${eword}(?:[@~]|\{\{.*|$)" <<<"${original}"; then
50-
##! result="${result}${eword}\n"
51-
##! result="${result}${eword}@\n"
52-
##! result="${result}${eword}~\n"
53-
##! result="${result}${eword}{{space-or-redirect}}\n"
54-
##! result="${result}${eword}{{no-space}}\n"
51+
##! result="${result}${eword}${NL}"
52+
##! result="${result}${eword}@${NL}"
53+
##! result="${result}${eword}~${NL}"
54+
##! result="${result}${eword}{{space-or-redirect}}${NL}"
55+
##! result="${result}${eword}{{no-space}}${NL}"
5556
##! fi
5657
##! done <<<"${1}"
5758
##! }

regex-assembly/include/unix-shell-4andup-with-params.ra

Lines changed: 108 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -4,31 +4,69 @@
44
##! This list was generated from the original lists with the following command:
55
##! awk '/^([a-z0-9_-]+)/ { x = $0; gsub(/[@~]/, "", x); if (length(x) > 3) print }' 93210{0,5}.data
66

7+
##! Note that the suffixes must be added manually to new entries.
8+
##! To regenerate this list from unix-shell.data, run the following:
9+
##! NL=$'\n'
10+
##! original="$(grep -vE '^[#$]' regex-assembly/include/unix-shell-4andup-with-params.ra)"
11+
##! source="$(awk '/^[^#$]/ {split($0,x,"/"); y=x[length(x)]} length(y) > 3 {print y}' \
12+
##! rules/unix-shell.data | \
13+
##! sort | uniq)"
14+
##! result=""
15+
##! # retain all unmodified entries in this list and skip removed ones; ignore the manually added suffixes
16+
##! while read -r oword; do
17+
##! while read -r sword; do
18+
##! # strip suffixes from end of words
19+
##! oword_raw="${oword/%\{\{space-or-redirect\}\}/}"
20+
##! oword_raw="${oword_raw/%\{\{no-space\}\}/}"
21+
##! if [ "${oword_raw}" = "${sword}" ]; then
22+
##! result="${result}${oword}${NL}"
23+
##! break
24+
##! fi
25+
##! done <<<"${source}"
26+
##! done <<<"${original}"
27+
28+
##! # add new entries to this list
29+
##! while read -r sword; do
30+
##! found=0
31+
##! while read -r oword; do
32+
##! # strip suffixes from end of words
33+
##! oword_raw="${oword/%\{\{space-or-redirect\}\}/}"
34+
##! oword_raw="${oword_raw/%\{\{no-space\}\}/}"
35+
##! if [ "${oword_raw}" = "${sword}" ]; then
36+
##! found=1
37+
##! break
38+
##! fi
39+
##! done <<<"${original}"
40+
##! if [ ${found} -eq 0 ]; then
41+
##! result="${result}${sword}${NL}"
42+
##! fi
43+
##! done <<<"${source}"
44+
745
##! # check entries for English words and suffix those
8-
##! original="$(grep -vE '^(?:#|$)' regex-assembly/include/unix-shell-4andup-with-params.ra)"
9-
##! english="$(util/fp-finder/spell.sh -m -e regex-assembly/include/unix-shell-4andup-with-params.ra)"
46+
##! original="${result}"
47+
##! english="$(util/fp-finder/spell.sh -m -e - <<<"${result}")"
1048
##! result=""
1149
##! while read -r oword; do
1250
##! found=0
1351
##! while read -r eword; do
14-
##! if [ "${oword}" = "${eword}" ]; then
15-
##! result="${result}${oword}{{space-or-redirect}}\n"
52+
##! if [ "${oword}" = "${eword}" ] && [ -n "${oword}" ]; then
53+
##! result="${result}${oword}{{space-or-redirect}}${NL}"
1654
##! found=1
1755
##! break
1856
##! fi
19-
##! done <<<${english}
57+
##! done <<<"${english}"
2058
##! if [ ${found} -eq 0 ]; then
21-
##! result="${result}${oword}\n"
59+
##! result="${result}${oword}${NL}"
2260
##! fi
23-
##! done <<<${original}
61+
##! done <<<"${original}"
2462

2563
##! body_start=$(grep -n -E -m 1 '^[^#$]' regex-assembly/include/unix-shell-4andup-with-params.ra | cut -d: -f1)
2664
##! ed -s regex-assembly/include/unix-shell-4andup-with-params.ra <<EOF
2765
##! $((body_start - 1)),\$d
2866
##! w
2967
##! q
3068
##! EOF
31-
##! echo ${result} | sort | uniq >> regex-assembly/include/unix-shell-4andup-with-params.ra
69+
##! echo "${result}" | sort | uniq >> regex-assembly/include/unix-shell-4andup-with-params.ra
3270

3371
##! The two `shell` entries match `$SHELL` and `${SHELL}`.
3472

@@ -39,6 +77,7 @@
3977

4078
HEAD{{space-or-redirect}}
4179
POST{{space-or-redirect}}
80+
addgroup
4281
adduser
4382
agetty
4483
alias{{space-or-redirect}}
@@ -52,11 +91,14 @@ ascii-xfr
5291
ascii85
5392
aspell
5493
atobm
94+
axel
5595
base32
5696
base64
97+
basename{{space-or-redirect}}
5798
basenc
5899
bash{{space-or-redirect}}
59100
batch{{space-or-redirect}}
101+
blkid
60102
bpftrace
61103
breaksw
62104
bridge{{space-or-redirect}}
@@ -69,6 +111,7 @@ bunzip2
69111
busctl
70112
busybox
71113
byebug
114+
byobu
72115
bzcat
73116
bzcmp
74117
bzdiff
@@ -77,6 +120,7 @@ bzexe
77120
bzfgrep
78121
bzgrep
79122
bzip2
123+
bzip2recover
80124
bzless
81125
bzmore
82126
cancel{{space-or-redirect}}
@@ -92,10 +136,16 @@ check_raid
92136
check_ssl_cert
93137
check_statusfile
94138
chflags
139+
chgpasswd
140+
chgrp
95141
chmod
96142
choom
97143
chown
144+
chpass
98145
chroot{{space-or-redirect}}
146+
chsh
147+
clang++
148+
clang{{space-or-redirect}}
99149
cobc
100150
column{{space-or-redirect}}
101151
comm
@@ -109,6 +159,7 @@ cpan
109159
cpio
110160
cpulimit
111161
crash{{space-or-redirect}}
162+
cron
112163
crontab
113164
csplit
114165
csvtool
@@ -128,6 +179,7 @@ done{{space-or-redirect}}
128179
dosbox
129180
dpkg
130181
dvips
182+
e2fsck
131183
easy_install
132184
echo{{space-or-redirect}}
133185
efax
@@ -168,11 +220,14 @@ ghci
168220
gimp{{space-or-redirect}}
169221
ginsh
170222
grep{{space-or-redirect}}
223+
groupmod
224+
group{{space-or-redirect}}
171225
gtester
172226
gunzip
173227
gzcat
174228
gzexe
175229
gzip
230+
hash{{space-or-redirect}}
176231
head{{space-or-redirect}}
177232
hexdump
178233
highlight{{space-or-redirect}}
@@ -181,6 +236,7 @@ hostid
181236
hostname
182237
hping3
183238
htdigest
239+
htop
184240
htpasswd
185241
iconv
186242
ifconfig
@@ -220,6 +276,7 @@ loginctl
220276
logname
221277
logsave
222278
look{{space-or-redirect}}
279+
losetup
223280
ls-F
224281
lsb_release
225282
lscpu
@@ -236,6 +293,8 @@ lwp-dump
236293
lwp-mirror
237294
lwp-request
238295
lynx{{space-or-redirect}}
296+
lz4c
297+
lz4cat
239298
lzcat
240299
lzcmp
241300
lzdiff
@@ -244,13 +303,19 @@ lzfgrep
244303
lzgrep
245304
lzless
246305
lzma
306+
lzmadec
307+
lzmainfo
247308
lzmore
248309
mailq
249310
mailx{{space-or-redirect}}
250311
mail{{space-or-redirect}}
251312
make{{space-or-redirect}}
313+
master.passwd
252314
mawk
253315
mkdir{{space-or-redirect}}
316+
mkfifo
317+
mknod
318+
mktemp
254319
mlocate
255320
more{{space-or-redirect}}
256321
mosquitto
@@ -271,12 +336,13 @@ mysqlshow
271336
nano{{space-or-redirect}}
272337
nasm
273338
nawk
274-
nc\.openbsd
275-
nc\.traditional
339+
nc.openbsd
340+
nc.traditional
276341
ncat
277342
neofetch
278343
netcat
279344
netkit-ftp
345+
netplan
280346
netstat
281347
nice{{space-or-redirect}}
282348
nmap
@@ -287,25 +353,31 @@ nroff
287353
nsenter
288354
nslookup
289355
nstat
356+
null{{space-or-redirect}}
290357
octave{{space-or-redirect}}
291358
onintr
292359
openssl
293360
openvpn
294361
openvt
295362
opkg
296363
pacman{{space-or-redirect}}
364+
parted{{space-or-redirect}}
297365
passwd
298366
paste{{space-or-redirect}}
299367
patch{{space-or-redirect}}
300368
pdflatex
301369
pdftex
370+
pdksh
302371
perf
303372
perl
304373
perl5
305374
perlsh
306375
perms{{space-or-redirect}}
307376
pftp
308377
pgrep
378+
php-cgi
379+
php5
380+
php7
309381
pico{{space-or-redirect}}
310382
pidstat
311383
pigz
@@ -317,16 +389,21 @@ pkill
317389
popd
318390
printenv
319391
printf{{space-or-redirect}}
392+
psed
320393
psftp
321394
psql
322395
ptar
323396
ptardiff
324397
ptargrep
325398
puppet{{space-or-redirect}}
326399
pushd
400+
pwd.db
401+
python2
402+
python3
327403
python{{no-space}}
328404
rake{{space-or-redirect}}
329405
raku
406+
rbash
330407
readelf
331408
realpath
332409
redcarpet{{space-or-redirect}}
@@ -354,16 +431,17 @@ sched
354431
screen{{space-or-redirect}}
355432
script{{space-or-redirect}}
356433
sdiff
434+
self{{space-or-redirect}}
357435
sendmail
358436
service{{space-or-redirect}}
359437
setarch
360438
setenv
361439
setfacl{{space-or-redirect}}
362440
setsid
363441
sftp
364-
sh\.distrib
365-
shell{{space-or-redirect}}
366-
shell}
442+
sh.distrib
443+
shadow{{space-or-redirect}}
444+
shells{{space-or-redirect}}
367445
shuf
368446
shutdown{{space-or-redirect}}
369447
sleep{{space-or-redirect}}
@@ -375,12 +453,16 @@ soelim
375453
sort{{space-or-redirect}}
376454
source{{space-or-redirect}}
377455
split{{space-or-redirect}}
456+
spwd.db
378457
sqlite3
379458
ssh-keygen
380459
ssh-keyscan
381460
sshpass
382461
start-stop-daemon
383462
stdbuf
463+
stderr
464+
stdin
465+
stdout
384466
strace
385467
strings{{space-or-redirect}}
386468
sudo
@@ -467,12 +549,25 @@ zcat
467549
zcmp
468550
zdiff
469551
zegrep
552+
zero{{space-or-redirect}}
470553
zfgrep
471554
zgrep
555+
zipcloak
556+
zipcmp
472557
zipdetails
558+
zipgrep
559+
zipinfo
560+
zipmerge
561+
zipnote
562+
zipsplit
563+
ziptool
473564
zless
474565
zmore
475566
zrun
476567
zsoelim
477568
zstd
569+
zstdcat
570+
zstdgrep
571+
zstdless
572+
zstdmt
478573
zypper

0 commit comments

Comments
 (0)