[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[feature request] parameter transformation to safely add strings to PS1,
From: |
Emanuele Torre |
Subject: |
[feature request] parameter transformation to safely add strings to PS1, &c. |
Date: |
Sun, 22 Aug 2021 23:11:53 +0200 |
It would be nice to have a parameter transformation (e.g. "${par@p}")
that expands $par to a string that will not be expanded by PS1, PS2, &c.
example:
tmp_var=$(blabla) # this variable will not exist when PS1 is expanded
PS1="blabla ${tmp_var@p} blabla"
I think a valid way to achieve the same behaviour in the currenct
version of bash:
tmp_var=$(blabla)
tmp_var=${tmp_var//\\/\\\\}
tmp_var=${tmp_var//\`/\\\`}
tmp_var=${tmp_var//$/\\$}
PS1="blabla $tmp_var blabla"
But a parameter transformation would be nicer.
This parameter transformation should also make sure to not cause an
expansion when concatenated.
var='$'
printf '%s\n' "${var@p}" # should not expand to `$'.
PS1="${var@P}(date)" # because this should expand to `$(date)'
# and not to the output of `date'.
Cheers,
emanuele6
- [feature request] parameter transformation to safely add strings to PS1, &c.,
Emanuele Torre <=
- Re: [feature request] parameter transformation to safely add strings to PS1, &c., Alex fxmbsw7 Ratchev, 2021/08/22
- Re: [feature request] parameter transformation to safely add strings to PS1, &c., Emanuele Torre, 2021/08/22
- Re: [feature request] parameter transformation to safely add strings to PS1, &c., Emanuele Torre, 2021/08/22
- Re: [feature request] parameter transformation to safely add strings to PS1, &c., Emanuele Torre, 2021/08/22
- Re: [feature request] parameter transformation to safely add strings to PS1, &c., Alex fxmbsw7 Ratchev, 2021/08/22
- Re: [feature request] parameter transformation to safely add strings to PS1, &c., Alex fxmbsw7 Ratchev, 2021/08/22
- Re: [feature request] parameter transformation to safely add strings to PS1, &c., Alex fxmbsw7 Ratchev, 2021/08/22
Re: [feature request] parameter transformation to safely add strings to PS1, &c., Koichi Murase, 2021/08/22