Clean POSIX checking script + POSIXed scripts

This commit is contained in:
inigoortega 2019-08-15 00:39:18 +02:00
parent c0a3c23366
commit 2537106be9
5 changed files with 34 additions and 8 deletions

View File

@ -1,4 +1,4 @@
#!/bin/bash
#!/bin/sh
DMENU=${DMENU:-dmenu}
@ -9,15 +9,15 @@ cmd_list="play stop next prev toggle add volume seek repeat single consume rando
mpc_add() {
file="$(mpc listall | ${DMENU} -l 15 -p "$prompt_add")"
[[ -z $file ]] && exit 1
[ -z $file ] && exit 1
mpc add "$file"
mpc play
}
cmd="$(echo $cmd_list | sed 's/ /\n/g' | ${DMENU} -p "$prompt")"
[[ -z $cmd ]] && exit 1
[ -z $cmd ] && exit 1
if [[ $cmd = add ]]; then
if [ $cmd = add ]; then
mpc_add
else
mpc $cmd

View File

@ -10,6 +10,6 @@ PROMPT="pwsafe $@"
item=$(eval ${DMENU} -p \""$PROMPT\"" < "$PWLIST")
[[ -z $item ]] && exit 1
[ -z $item ] && exit 1
${TERMCMD} -name pass -e pwsafe $@ "$item" --

View File

@ -2,7 +2,7 @@
DMENU=${DMENU:-dmenu}
if [[ -f $HOME/.tmux/attach.list ]]; then
if [ -f $HOME/.tmux/attach.list ]; then
. $HOME/.tmux/attach.list
fi
@ -18,6 +18,6 @@ spawn_local() {
target=$(echo $tmux_pre $tmux_run | sed 's/ /\n/g' | sort -u | eval ${DMENU} -p "$prompt")
if [[ -n $target ]]; then
if [ -n $target ]; then
spawn_local $target
fi

View File

@ -57,7 +57,7 @@ dmenu_mnt() {
0) urgency="normal";;
*) urgency="critical";;
esac
notify-send -u $urgency "$(<$TMP)"
notify-send -u $urgency "$(cat $TMP)"
else
cat "$TMP"
fi

26
termscripts/posix-check.sh Executable file
View File

@ -0,0 +1,26 @@
#!/bin/sh
output="/tmp/posix-check-$(date +%s)"
checkbashisms -f $SCRIPTS/*.sh $TSCRIPTS/*.sh > $output 2>&1
errorline () {
[ -n "$(echo "$1" | grep '(unsafe echo with backslash)')" ] && echo "1" && \
return
[ -n "$(echo "$1" | grep '($"foo" should be eval_gettext "foo")')" ] && \
echo "1" && return
[ -n "$(echo "$1" | grep '(\[^\] should be \[!\])')" ] && echo "1" && return
[ -n "$(echo "$1" | grep -E "bashism in ($SCRIPTS|$TSCRIPTS)/.*\\.sh")" ] && echo "2" && return
echo "0"
}
bashism="0"
while read -r line
do
# echo "$(errorline "$line")"
case "$(errorline "$line")" in
0) ;;
1) bashism="0" ;;
2) bashism="1" ;;
esac
[ "$bashism" = "1" ] && echo "$line"
done < $output