bash, echo or openssl bug?
Configuration Information [Automatically generated, do not change]: Machine: x86_64 OS: linux-gnu Compiler: gcc Compilation CFLAGS: -DPROGRAM='bash' -DCONF_HOSTTYPE='x86_64' -DCONF_OSTYPE='linux-gnu' -DCONF_MACHTYPE='x86_64-pc-linux-gnu' -DC$ uname output: Linux buildserver 2.6.27-11-server #1 SMP Wed Apr 1 21:34:13 UTC 2009 x86_64 GNU/Linux Machine Type: x86_64-pc-linux-gnu Bash Version: 3.2 Patch Level: 39 Release Status: release Description: i dont know if the bug is a bash bug or openssl or echo, but when i echo a string and pipe it to openssl, the output comes on the same line as the prompt instead of a new line. it makes the output hard to read because it is prepended to the prompt text, e.g. mySecretPasswordtcadmin@buildserver: ~$ Repeat-By: 1. run the following code in bash terminal: echo OHBjcWNLNGlQaVF5 | openssl base64 -d 2. the output in the bash terminal looks like this: mySecretPasswordtcadmin@buildserver: ~$ 3. the output SHOULD look like this: mySecretPassword tcadmin@buildserver: ~$
bash, echo or openssl bug?
Configuration Information [Automatically generated, do not change]: Machine: x86_64 OS: linux-gnu Compiler: gcc Compilation CFLAGS: -DPROGRAM='bash' -DCONF_HOSTTYPE='x86_64' -DCONF_OSTYPE='linux-gnu' -DCONF_MACHTYPE='x86_64-pc-linux-gnu' -DCONF_VENDOR='pc' -DLOCALEDIR='/usr/share/locale' -DPACKAGE='bash' -DSHELL -DHAVE_CONFIG_H -I. -I../bash -I../bash/include -I../bash/lib -g -O2 -Wall uname output: Linux buildserver 2.6.27-11-server #1 SMP Wed Apr 1 21:34:13 UTC 2009 x86_64 GNU/Linux Machine Type: x86_64-pc-linux-gnu Bash Version: 3.2 Patch Level: 39 Release Status: release Description: i dont know if the bug is a bash bug or openssl or echo, but when i echo a string and pipe it to openssl, the output comes on the same line as the prompt instead of a new line. it makes the output hard to read because it is prepended to the prompt text, e.g. mySecretPasswordtcadmin@buildserver: ~$ Repeat-By: 1. run the following code in bash terminal: echo OHBjcWNLNGlQaVF5 | openssl base64 -d 2. the output in the bash terminal looks like this: mySecretPasswordtcadmin@buildserver: ~$ 3. the output SHOULD look like this: mySecretPassword tcadmin@buildserver: ~$
let's set the positional parameters with a simple 'read'
One can do $ read p to set $p but no just as easy method to set $@, $1, etc. One must do $ set -- `cat` #which involves ^D, "too much trouble" Or set -- `read x; echo "$x"` etc. No, nothing as easy as $ read 1 sds bash: read: `1': not a valid identifier $ read @ sdss bash: read: `@': not a valid identifier Regretful. How about just $ set -- sds you say. Well that won't work as good as $ read x http://www.youtube.com/watch?v=PLTOc2TVAs8&list=PL54881C422E6B58FC $ When one is pasting URLs with the mouse, and they contain special characters. Yes one could do $ set '' but that is a little more fuss. So I propose we 'wreck the language' to allow me to do $ read @ to set $@, same with 1, 2,.. * (almost the same as @).
Re: bash, echo or openssl bug?
On 01/03/2012 06:48 AM, nick humphrey wrote: > Description: > i dont know if the bug is a bash bug or openssl or echo, but when i > echo a string and pipe it to openssl, the > output comes on the same line as the prompt instead of a new line. None of the above. It's not a bug. Your encoded string does not have a trailing newline, and your $PS1 settings don't inject a starting newline, so the behavior is expected. If you want to guarantee a trailing newline, then add one manually: > 1. run the following code in bash terminal: > echo OHBjcWNLNGlQaVF5 | openssl base64 -d echo OHBjcWNLNGlQaVF5 | openssl base64 -d && echo or modify your PS1 to start with a newline request. -- Eric Blake ebl...@redhat.com+1-919-301-3266 Libvirt virtualization library http://libvirt.org signature.asc Description: OpenPGP digital signature
Re: let's set the positional parameters with a simple 'read'
On Wed, Jan 04, 2012 at 01:16:27AM +0800, jida...@jidanni.org wrote: > So I propose we 'wreck the language' to allow me to do > $ read @ > to set $@, same with 1, 2,.. * (almost the same as @). Why not just use a named array? $ read -a myarray
Re: let's set the positional parameters with a simple 'read'
On 01/03/2012 10:16 AM, jida...@jidanni.org wrote: > One can do > $ read p > to set $p > but no just as easy method to set $@, $1, etc. > One must do > $ set -- `cat` #which involves ^D, "too much trouble" > Or set -- `read x; echo "$x"` etc. No need for a subshell to do what you want. Just do: read p set -- "$p" to set $1, or read p set -- $p to set all of $@ according to the IFS splitting of $p. > > So I propose we 'wreck the language' to allow me to do > $ read @ > to set $@, same with 1, 2,.. * (almost the same as @). Sorry, I don't think this is worth doing. -- Eric Blake ebl...@redhat.com+1-919-301-3266 Libvirt virtualization library http://libvirt.org signature.asc Description: OpenPGP digital signature
Re: let's set the positional parameters with a simple 'read'
On Tue, Jan 3, 2012 at 7:16 PM, wrote: ... > So I propose we 'wreck the language' to allow me to do > $ read @ > to set $@, same with 1, 2,.. * (almost the same as @). > Since you can use "read -a arr" to set arr[1] arr[2] ...etc it's not that interesting Setting the positional parameters is really only useful as tricks in shells that don't have function local variables or arrays.
Re: bash, echo or openssl bug?
On Tuesday 03 January 2012 08:48:27 nick humphrey wrote: > Description: > i dont know if the bug is a bash bug or openssl or echo, but when i > echo a string and pipe it to openssl, the > output comes on the same line as the prompt instead of a new line. it makes > the output hard to read because it is prepended > to the prompt text, e.g. mySecretPasswordtcadmin@buildserver: ~$ > > Repeat-By: > 1. run the following code in bash terminal: > echo OHBjcWNLNGlQaVF5 | openssl base64 -d > > 2. the output in the bash terminal looks like this: > mySecretPasswordtcadmin@buildserver: ~$ there is no bug in any of these packages. openssl doesn't include a trailing new line. > 3. the output SHOULD look like this: > mySecretPassword > tcadmin@buildserver: ~$ then add it yourself: $ echo OHBjcWNLNGlQaVF5 | openssl base64 -d; echo $ out=$(echo OHBjcWNLNGlQaVF5 | openssl base64 -d); echo "${out}" ... many other ways ... -mike signature.asc Description: This is a digitally signed message part.
Re: let's set the positional parameters with a simple 'read'
> "GW" == Greg Wooledge writes: GW> Why not just use a named array? GW> $ read -a myarray But does that let me get a my favorite array, the positional parameters?
Re: let's set the positional parameters with a simple 'read'
On 01/03/2012 10:46 AM, jida...@jidanni.org wrote: >> "GW" == Greg Wooledge writes: > GW> Why not just use a named array? > GW> $ read -a myarray > But does that let me get a my favorite array, the positional parameters? Any time you want to assign the positional parameters, use set. It's as simple as that. What's wrong with: read -a myarray set -- "${myarray[@]}" -- Eric Blake ebl...@redhat.com+1-919-301-3266 Libvirt virtualization library http://libvirt.org signature.asc Description: OpenPGP digital signature
Re: let's set the positional parameters with a simple 'read'
2012-01-04, 01:46(+08), jida...@jidanni.org: >> "GW" == Greg Wooledge writes: >GW> Why not just use a named array? >GW> $ read -a myarray > But does that let me get a my favorite array, the positional parameters? FWIW, in zsh: ~$ read -A argv a b c ~$ echo $1 a ~$ read 1 x ~$ echo $1 x See also vared argv and vared 1 to edit them with the zsh line editor (zle, the bash equivalent would be readline as invoked by read -e) -- Stephane
Re: bash, echo or openssl bug?
thanks eric and mike for your quick reply and suggestions =) 2012/1/3 Eric Blake > On 01/03/2012 06:48 AM, nick humphrey wrote: > > Description: > > i dont know if the bug is a bash bug or openssl or echo, but > when i > > echo a string and pipe it to openssl, the > > output comes on the same line as the prompt instead of a new line. > > None of the above. It's not a bug. Your encoded string does not have a > trailing newline, and your $PS1 settings don't inject a starting > newline, so the behavior is expected. If you want to guarantee a > trailing newline, then add one manually: > > > 1. run the following code in bash terminal: > > echo OHBjcWNLNGlQaVF5 | openssl base64 -d > > echo OHBjcWNLNGlQaVF5 | openssl base64 -d && echo > > or modify your PS1 to start with a newline request. > > -- > Eric Blake ebl...@redhat.com+1-919-301-3266 > Libvirt virtualization library http://libvirt.org > >
Re: let's set the positional parameters with a simple 'read'
Hmmm, as S. CHAZELAS said seems zsh also gives one a chance to reset an arbitrary positional parameter, e.g., the 42nd, whereas in bash one must set them all at once: $ set `seq 55` $ echo $42 42 $ echo $66 66 :-) Anyway isn't it rather old fashioned not to be able to somehow reset ${42} without needing to tamper with the rest?