[OpenWrt-Devel] Hang on setting $PROMPT in master

Martin Tippmann martin.tippmann at gmail.com
Mon Oct 21 11:04:23 EDT 2019


We are using a shell-function to set the prompt based on return code -
it works fine in 17.01 / 18.06 / 19.07, however in current master when
the function is run the terminal/ssh session hangs.

how to reproduce:



<--- hang.sh:
#!/bin/sh

prompt_set() {
   face() {
    local rc=$?
    case "$rc" in
       0) printf '%s' "$1" ;;
       *) printf '%s' "$2" ; return $rc ;;
      esac
   }

   local e='\[\e' # start escape-sequence
   local c='\]' # close escape-sequence

   local user='\u'
   local wdir='\w' # workdir
   local host='\h' # short form

    local reset="${e}[0m${c}" # all attributes
    local white="${e}[37m${c}"
    local cyan="${e}[36m${c}"
    local yellow="${e}[33;1m${c}" # bold
    local green="${e}[32m${c}"
    local red="${e}[31m${c}"

    local ok="${green}:)"
    local bad="${red}8("

   # e.g. user at hostname:~ :)
   export PS1="${cyan}${user}$white@${green}$host:${yellow}$wdir \$(
face '$ok' '$bad' ) $reset"
}

prompt_set
-->

now source the file:

. ./hang.sh

shellcheck does not complain - I'm writing because I'm not sure wether
this invalid sh that happened to work anyway or is this a
bug/regression in ash?

regards
Martin

_______________________________________________
openwrt-devel mailing list
openwrt-devel at lists.openwrt.org
https://lists.openwrt.org/mailman/listinfo/openwrt-devel



More information about the openwrt-devel mailing list