Why does/would the following printf statement behave differently based upon ...? (GNU bash, version 4.4.18(1)-release (x86_64-pc-linux-gnu))
printf "%s : %s : %s\n" $TERM ${TERM//[^[:alnum:]]/_} ${TERM//[^[:alnum:]]/?}
When in an unprivileged user terminal session in tmux, the output is:
screen-256color : screen_256color : screen?256color
However, when in a root terminal, for the same tmux session the output is:
xterm-256color : xterm_256color :
Outside of tmux, the output is the same failure for all users:
xterm-256color : xterm_256color :
ADDITIONAL INFORMATION:
I just tried the same command line, but replacing the question mark with an asterisk, and the same failures and successes occur. Could it be an issue related somehow to globbing? The field is supposed to be treated as a string value, not a glob. Then I tried escaping the character and get the following results, for the six cases of asterisk plain, with one backslash, and with two backslashes, for xterm-256color and screen-256-color cases mentioned above:
printf "%s : %s : %s\n" $TERM ${TERM//[^[:alnum:]]/_} ${TERM//[^[:alnum:]]/*}
screen-256color : screen_256color : screen*256color
xterm-256color : xterm_256color :
printf "%s : %s : %s\n" $TERM ${TERM//[^[:alnum:]]/_} ${TERM//[^[:alnum:]]/\*}
screen-256color : screen_256color : screen*256color
xterm-256color : xterm_256color :
printf "%s : %s : %s\n" $TERM ${TERM//[^[:alnum:]]/_} ${TERM//[^[:alnum:]]/\\*}
screen-256color : screen_256color : screen\*256color
xterm-256color : xterm_256color : xterm\*256color
screenfor one but not the other. Are you? – Chris Davies Mar 13 '18 at 13:52tmuxsession (kind of likescreen) on the same host. I just tried the example outside oftmuxand it fails even for a regular account (with TERM=xterm-256color), so I need to update the question. Not sure exactly how to re-frame it yet ... – user1404316 Mar 13 '18 at 14:11tmuxis debian package version 2.63 – user1404316 Mar 13 '18 at 14:35tmux, the same error occurs. It's beginning to correlate to the value of TERM being eitherscreen-256colororxterm-256coloror whether it happens in or out oftmux. – user1404316 Mar 13 '18 at 14:51