Re: passing array to command line argument.
Chet Ramey writes: > Dolphin06 wrote: >> I dont get it right, i always display only the first one, and i dont know how >> to write a scalar variable. >> I tried like this : >> ssh $u...@$server script2 -f "${my_arr...@]}" > > Stick an `echo' in front of this command and see what you're executing. Better yet: set -x to get an accurate view of the command, including quoting. Andreas. -- Andreas Schwab, SuSE Labs, sch...@suse.de SuSE Linux Products GmbH, Maxfeldstraße 5, 90409 Nürnberg, Germany PGP key fingerprint = 58CA 54C7 6D53 942B 1756 01D3 44D5 214B 8276 4ED5 "And now for something completely different."
Formating variable with caracter and date.
Hello all, I would like to give a variable a value which have a format like this one: <3 letters>-- should be yymmdd. Date of the day by default. How would i do this, i know the date command is date +"%y-%m-%d", but i dont know the syntax for mixing letters date and digit into one variable. Also i would like to give the user a chance to change this default value, by letting him enter one, so i would like to know how can i check if the entered value is in the correct format. Thank you for helping. -- View this message in context: http://www.nabble.com/Formating-variable-with-caracter-and-date.-tp20973500p20973500.html Sent from the Gnu - Bash mailing list archive at Nabble.com.
Re: Formating variable with caracter and date.
Dolphin06 wrote: > Hello all, > > I would like to give a variable a value which have a format like this one: > <3 letters>-- > should be yymmdd. Date of the day by default. > How would i do this, i know the date command is date +"%y-%m-%d", but i dont > know the syntax for mixing letters date and digit into one variable. > Also i would like to give the user a chance to change this default value, by > letting him enter one, so i would like to know how can i check if the > entered value is in the correct format. First of all, this list if for reporting bash bugs, not for general help requests. For that purpose, there are other, more appropriate, places, like for example the Internet newsgroup comp.unix.shell. Then, regarding your request: To assign that string to the variable, assuming <3 letters> is "ABC", and is "5" (replace with your own values), you can do this: var=ABC-$(date +%y%m%d)-5 The part about checking depends on what you want to check exactly, which isn't clear from your description. -- D.
Re: SIGPIPE not properly reset with 'trap - PIPE'
Ralf Wildenhues wrote: > Hello bug-bash readers, > > I noticed the following bash bug when using gnulib-tool. The script > below outputs > > foo: line 20: echo: write error: Broken pipe > foo: line 21: echo: write error: Broken pipe > > with bash 3.2.48(5)-release on GNU/Linux, whereas I think it should be > silent. Please note that the script assumes that GNU coreutils seq is > installed. This is the result of two much-requested changes to bash that appeared in bash-3.2. The first has to do with signals that cause the shell to terminate. The shell has to do a fair amount of cleanup work before it exits, especially interactive shells -- job control, tty restoration, maybe saving the history, and so on. There were lots of complaints that the shell was doing too much, and calling too many disallowed functions, in a signal handler, so bash-3.2 changed to setting a `terminating signal received' flag on signal receipt and handling the condition later. SIGPIPE is such a signal. (There is also a way to tell bash to just shut up and exit on a terminating signal, standards be damned.) The second is that the echo builtin in bash-3.2 displays a message on a write error, instead of letting the exit status communicate the error. When the shell receives SIGPIPE and handles it without exiting, writes to that pipe return -1/EPIPE, and the echo builtin reports the error. In earlier versions, you wouldn't have seen the message. The fix is to add more checks for receipt of terminating signals and to tell the shell to exit right away if executing an `output builtin' like echo or printf when a terminating signal is caught. It will be in bash-4.0. Chet -- ``The lyf so short, the craft so long to lerne.'' - Chaucer Chet Ramey, ITS, CWRUc...@case.eduhttp://cnswww.cns.cwru.edu/~chet/
Re: binding key sequence "js" to vi-command-mode?
Britton Kerin wrote: > I'm wondering if its possible to emulate this behavior in bash. I > tried: > > bind -m vi-insert "js": vi-command-mode > > but it doesn't seem to work: typing the sequence from insert mode > just beeps when j is typed and then the s gets inserted. It doesn't work because that's not the name of the command and you have the key binding syntax slightly wrong. Try bind -m vi-insert '"js":vi-movement-mode' which works fine for me using bash-3.2.48. Chet -- ``The lyf so short, the craft so long to lerne.'' - Chaucer Chet Ramey, ITS, CWRUc...@case.eduhttp://cnswww.cns.cwru.edu/~chet/
Re: vi editing mode + color prompt = trouble?
Halim Issa wrote: > On bash 3.2 patchlevel 048 (and earlier) there appears to be problems in vi > mode and prompts containing escape characters (such as to get bold text). > > To reproduce: > Enter vi editing mode set -o vi > > Set the following prompt: > export PS1="[\!] \[\e[1m\]\u\[\e[...@\h:\w>" > > Type "one two three four five six seven eight" press ESCape and 7 B to go > seven words back. This takes me right in the middle of the prompt while > displaying (args:7) on the prompt. Once it removes the (args:7) info, ie when > I press the "B", the cursor location is messed up and I end up in the middle > of the prompt, instead of at the word "two" where I should be. I can't reproduce this with xterm, aterm, or Terminal on Mac OS X with bash-3.2.48. I have made display fixes for possibly-related problems displaying numeric arguments; maybe those will fix your problem. They will come out with bash-4.0. Chet -- ``The lyf so short, the craft so long to lerne.'' - Chaucer Chet Ramey, ITS, CWRUc...@case.eduhttp://cnswww.cns.cwru.edu/~chet/
command substitution and word splitting
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 Gauss 2.6.24-22-generic #1 SMP Mon Nov 24 19:35:06 UTC 2008 x86_64 GNU/Linux Machine Type: x86_64-pc-linux-gnu Bash Version: 3.2 Patch Level: 39 Release Status: release Description: i want to start building a project with ./configure --prefix=... $(myflags) where myflags is an executable text file on my path. myflags has the following in it: printf 'CFLAGS="-O2 -fomit-frame-pointer" ' printf 'LDFLAGS="-Wl,-O2"' now, when i do that ./configure complains for not recognizing -fomit-frame-pointer option, and actually word splitting of bash ruins what i wanna do. i want the word splitting of a command substitution "to be careful about the quotes in the resulting expansion". is that possible? note: i have xubuntu 8.04 amd64 desktop, on a core2 dell laptop. Fix: something like $(command@) can be added to bash, retaining old functionality. the new one will warn (somehow) word splitting to be careful about possible quotes in the resulting expansion of the command substitution.