Browse Source

minor edits for shellcheck + add set -f to which (suggested by pystardust)

head
ThatGeekyWeeb 1 year ago
parent
commit
cfab8fb193
  1. 1
      bin/cat
  2. 5
      bin/grep
  3. 2
      bin/seq
  4. 4
      bin/tr
  5. 1
      bin/which
  6. 4
      shellcheck

1
bin/cat

@ -1,5 +1,4 @@ @@ -1,5 +1,4 @@
#!/bin/sh
# shellcheck disable=SC2015
LANG=C
print() {
printf "%s\\n" "$(while read -r p || [ -n "$p" ] ; do

5
bin/grep

@ -1,12 +1,11 @@ @@ -1,12 +1,11 @@
#!/bin/sh
# shellcheck disable=SC2015,SC2166
LANG=C; IFS="" # incase someone tries to use grep on a binary
rcase() {
n=0; while read -r p || [ -n "$p" ] ; do
case "$p" in
*"${1}"*)
: $((n+=1))
[ "$2" != "-q" ] && { IFS=""; printf "%s\\n" "$p"; } || { exit 0; }
[ "$2" != "-q" ] && { IFS=""; printf "%s\\n" "$p"; :;} || { exit 0; }
esac
done <&0 >&1
[ ! "$n" -gt 0 ] && exit 1
@ -27,5 +26,5 @@ n=1; for i in "$@"; do @@ -27,5 +26,5 @@ n=1; for i in "$@"; do
: $((n+=1))
done
# catch arg's regardless of placement :3 real grep doesn't do that
[ "$e" ] && { rcase "$s" "$q" <$e; exit 0; }
[ "$e" ] && { rcase "$s" "$q" <"$e"; exit 0; }
rcase "$s" "$q" <&0

2
bin/seq

@ -1,7 +1,7 @@ @@ -1,7 +1,7 @@
#!/bin/sh
s() {
n=$(($1)); i=${i:-1}; while [ "$n" -le $(($2)) ]; do
echo "$n"; : $((n+=$i))
echo "$n"; : $((n+=i))
done
}
case "$#" in

4
bin/tr

@ -14,8 +14,8 @@ operand(){ @@ -14,8 +14,8 @@ operand(){
##
new_line="
"
[ "$1" = '\n' ] && r1=$new_line || r1=$(printf "${1}")
[ "$2" = '\n' ] && r2=$new_line || r2=$(printf "${2}")
[ "$1" = '\n' ] && r1=$new_line || r1=$(printf '%s' "${1}")
[ "$2" = '\n' ] && r2=$new_line || r2=$(printf '%s' "${2}")
is_newline=1
if [ "$1" = '\n' ]; then
while read -r line || { is_newline=0 ; [ -n "$line" ];}; do

1
bin/which

@ -1,4 +1,5 @@ @@ -1,4 +1,5 @@
#!/bin/sh
set -f
IFS=":"; for i in ${PATH}; do
[ -f "$i/$1" ] && l="$l:$i/$1"
done

4
shellcheck

@ -0,0 +1,4 @@ @@ -0,0 +1,4 @@
# following are reasons for shellcheck warnings
SC2166: -o and -a are defined in posix
SC2015: I know what I'm doing + I use :;} ||
SC2048: intended
Loading…
Cancel
Save