|
Added
Link Here
|
| 1 |
- spout a warning when command completion cannot be used |
| 2 |
- try to guess whether sleep(1) supports fractions |
| 3 |
- remove GNUisms from sed(1) lines without breaking GNU sed usage |
| 4 |
- use termcap names, they have higher chance to work on FreeBSD |
| 5 |
|
| 6 |
diff --git contrib/stumpish~ contrib/stumpish |
| 7 |
index 1d48bb4..59c783e 100755 |
| 8 |
--- contrib/stumpish~ |
| 9 |
+++ contrib/stumpish |
| 10 |
@@ -21,10 +21,10 @@ |
| 11 |
|
| 12 |
### STUMPwm Interactive SHell. |
| 13 |
|
| 14 |
-if sleep --version 2>/dev/null | grep -q GNU |
| 15 |
+DELAY=0.01 |
| 16 |
+ |
| 17 |
+if ! sleep $DELAY 2>/dev/null >&2 |
| 18 |
then |
| 19 |
- DELAY=0.1 |
| 20 |
-else |
| 21 |
DELAY=1 |
| 22 |
fi |
| 23 |
|
| 24 |
@@ -49,8 +49,16 @@ wait_result () |
| 25 |
return 1 |
| 26 |
fi |
| 27 |
|
| 28 |
- echo $RESULT | sed 's/[^"]*"//;s/"$//;s/\\n/\n/g;s/\\"/"/g;s/\n\+$//; |
| 29 |
- s/\^[*[:digit:]]\{2\}//g;s/\^[Bbn]//g;' |
| 30 |
+ echo $RESULT | |
| 31 |
+ sed -E 's/[^"]*"// |
| 32 |
+ s/"$// |
| 33 |
+ s/([^\])\\n/\1\ |
| 34 |
+/g |
| 35 |
+ s/\\\\n/\\n/g |
| 36 |
+ s/\\"/"/g |
| 37 |
+ s/\\n[[:space:]]+$// |
| 38 |
+ s/\^[*[:digit:]]{2}//g |
| 39 |
+ s/\^[Bbn]//g' |
| 40 |
} |
| 41 |
|
| 42 |
send_cmd () |
| 43 |
@@ -121,24 +129,34 @@ then |
| 44 |
else |
| 45 |
if [ -t 0 ] |
| 46 |
then |
| 47 |
- if [ $READLINE = yes ] && type rlwrap >/dev/null 2>&1 |
| 48 |
+ if ! type rlwrap 2>/dev/null >&2 |
| 49 |
+ then |
| 50 |
+ tput md |
| 51 |
+ tput AF 1 |
| 52 |
+ echo -n WARN: |
| 53 |
+ tput me |
| 54 |
+ echo \ rlwrap not found, command completion won\'t work. >&2 |
| 55 |
+ elif [ $READLINE = yes ] |
| 56 |
then |
| 57 |
# Note: $TEMP is not conventional; it is left here purely |
| 58 |
# for backwards compatibility. |
| 59 |
- COMMANDS="${TEMP:-${TEMPDIR:-/var/tmp}}/stumpish.commands.$$" |
| 60 |
- echo `send_cmd "commands"` | sed 's/[[:space:]]\+/\n/g' | sort > "$COMMANDS" |
| 61 |
+ COMMANDS="${TEMPDIR:-/tmp}/stumpish.commands.$$" |
| 62 |
+ echo `send_cmd "commands"` | |
| 63 |
+ sed -E 's/[[:space:]]+/\ |
| 64 |
+/g' | |
| 65 |
+ sort > "$COMMANDS" |
| 66 |
rlwrap -f "$COMMANDS" "$0" -r |
| 67 |
rm -f "$COMMANDS" |
| 68 |
exit |
| 69 |
fi |
| 70 |
|
| 71 |
- tput setaf 5 |
| 72 |
+ tput AF 5 |
| 73 |
echo Welcome to the STUMPwm Interactive SHell. |
| 74 |
- tput sgr0 |
| 75 |
+ tput me |
| 76 |
echo -n 'Type ' |
| 77 |
- tput setaf 2 |
| 78 |
+ tput AF 2 |
| 79 |
echo -n commands |
| 80 |
- tput sgr0 |
| 81 |
+ tput me |
| 82 |
echo \ for a list of commands. |
| 83 |
|
| 84 |
IFS=' |
| 85 |
@@ -146,10 +164,10 @@ else |
| 86 |
echo -n "> " |
| 87 |
while read REPLY |
| 88 |
do |
| 89 |
- tput bold |
| 90 |
- tput setaf 2 |
| 91 |
+ tput md |
| 92 |
+ tput AF 2 |
| 93 |
send_cmd "$REPLY" |
| 94 |
- tput sgr0 |
| 95 |
+ tput me |
| 96 |
|
| 97 |
echo -n "> " |
| 98 |
done |