##! Please refer to the documentation at
##! https://coreruleset.org/docs/development/regex_assembly/.

##! Note that the suffixes @ / ~ must be added manually to new entries.
##! To regenerate this list from unix-shell.data, run the following:
##! NL=$'\n'
##! # select words of length <= 3
##! original="$(grep -vE '^[#$]' regex-assembly/include/unix-shell-upto3.ra)"
##! source=$(awk '/^[^#$]/ {split($0,x,"/"); y=x[length(x)]} length(y) <= 3 {print y}' \
##!   rules/unix-shell.data | \
##!   sort | uniq)
##! result=""
##! # retain all unmodified entries in this list and skip removed ones; ignore the manually added suffixes
##! while read -r oword; do
##!   # strip @ and ~ from end of words
##!   oword_raw="${oword/%@/}"
##!   oword_raw="${oword_raw/%\~/}"
##!   while read -r sword; do
##!     if [ "${oword_raw}" = "${sword}" ]; then
##!       result="${result}${oword}${NL}"
##!       break
##!     fi
##!   done <<<"${source}"
##! done <<<"${original}"

##! # add new entries to this list
##! while read -r sword; do
##!   found=0
##!   while read -r oword; do
##!     # strip @ and ~ from end of words
##!     oword_raw="${oword/%@/}"
##!     oword_raw="${oword_raw/%\~/}"
##!     if [ "${oword_raw}" = "${sword}" ]; then
##!       found=1
##!       break
##!     fi
##!   done <<<"${original}"
##!   if [ ${found} -eq 0 ]; then
##!     result="${result}${sword}${NL}"
##!   fi
##! done <<<"${source}"

##! # check entries for English words and suffix those
##! original="$(grep -vE '^[#$]' regex-assembly/include/unix-shell-upto3.ra)"
##! english="$(util/fp-finder/spell.sh -m -e regex-assembly/include/unix-shell-upto3.ra)"
##! # do not suffix the following words:
##! english="$(grep -vE 'ip|id|top|set' <<< "${english}")"
##! result=""
##! while read -r oword; do
##!   found=0
##!   while read -r eword; do
##!     if [ "${oword}" = "${eword}" ] && [ -n "${oword}" ]; then
##!       result="${result}${oword}@${NL}"
##!       found=1
##!       break
##!     fi
##!   done <<<"${english}"
##!   if [ ${found} -eq 0 ]; then
##!     result="${result}${oword}${NL}"
##!   fi
##! done <<<"${original}"

##! body_start=$(grep -n -E -m 1 '^[^#$]' regex-assembly/include/unix-shell-upto3.ra | cut -d: -f1)
##! ed -s regex-assembly/include/unix-shell-upto3.ra <<EOF
##! $((body_start - 1)),\$d
##! w
##! q
##! EOF
##! echo "${result}" | sort | uniq >> regex-assembly/include/unix-shell-upto3.ra

7z
7za
7zr
7zx
GET@
ab@
apt@
ar@
arj
arp@
as@
ash@
at@
awk@
aws@
bzz@
c89
c99
cat@
cc@
cmp
cp@
csh
cut@
dd@
df
dig@
dir@
dnf
du@
eb@
ed@
env@
eqn
es@
esh
ex@
fc@
fd
fg
fi@
fmt
ftp@
gcc~
gdb
gem@
ghc
git@
go@
gpg
grc
hd@
hup@
id
ip
irb
jjs
jq
ksh
ld@
ldd@
ln@
lp@
ls
lua@
lz4
lz@
man@
mtr
mv@
nc@
net@
nl@
nm@
npm@
od@
pax@
pdb
pf@
pg
php@
pic@
pip~
pkg
pr@
pry@
ps@
ptx
pwd
pxz
rar@
rc
rcp@
red@
rev@
rm@
rpm@
scp
sed@
set@
sg@
sh@
ss@
ssh@
su@
svn
tac
tar@
tbl
tcp@
tee@
tex@
tic@
top
udp
ul@
vi@
vim@
w3m
w@
wc
who@
xxd
xz@
yes@
yum
zip@
zsh
