siglist.c must #include bashintl.h

2009-02-24 Thread Greg Wooledge
siglist.c must #include bashintl.h -- bash 4.0 fails to build for me on HP-UX 10.20 with gcc, with unresolved symbol _ at final link time until I add that #include.

examples/loadable/finfo.c missing cast

2009-02-25 Thread Greg Wooledge
imadev:~$ enable -f /var/tmp/bash-4.0/examples/loadables/finfo finfo imadev:~$ ls -l .bashrc -rw-r--r-- 1 wooledgpgmr 331 Sep 16 14:30 .bashrc imadev:~$ finfo -s .bashrc 316732948 imadev:~$ finfo -s .bashrc 317115222 --- finfo.c.origWed Feb 25 10:07:12 2009 +++ finfo.c

Re: functions, process substitution, bad file descriptor

2009-02-27 Thread Greg Wooledge
On Fri, Feb 27, 2009 at 09:26:29AM -0500, Ben Hyde wrote: f2(){ date cat $1 } f2 (echo l8r) Fri Feb 27 09:18:45 EST 2009 cat: /dev/fd/63: Bad file descriptor For whatever it's worth, I can reproduce this behavior on both Linux and OpenBSD (which use /dev/fd/*), in several versions of

[PATCH] safelocale

2009-02-28 Thread Greg Wooledge
I wrote this after learning of a security hole in $... expansion. (See http://www.gnu.org/software/gettext/manual/html_node/bash.html for details of that.) It seems the maintainer of gettext is trying to push the use of the portable sh syntax, for example cd $var || error `eval_gettext \Can\'t

Re: 2 regressions related to PROMPT_COMMAND

2009-03-02 Thread Greg Wooledge
On Sun, Mar 01, 2009 at 10:29:00PM -0800, smallnow wrote: Bug #1: do: PROMPT_COMMAND='$(cd)' I've never found any reasonable use for PROMPT_COMMAND. If you just want to perform command substitutions at prompt-writing time, use PS1: PS1='$(pwd)\$ ' Of course, this trivial example is more

Re: manually pipe processes

2009-03-05 Thread Greg Wooledge
On Thu, Mar 05, 2009 at 12:28:00PM -0500, Brian J. Murrell wrote: tar cf - /etc | tar xf - | tee /tmp/outfile I want (specifically) the second tar command to run in the background and I want to wait for it so that the trap in the parent shell can process signals. Altogether I want:

Re: Bash question

2009-03-10 Thread Greg Wooledge
On Sun, Mar 08, 2009 at 03:56:30PM -0700, jenea wrote: This is my script: = #!/bin/bash today_day=$(echo `date +'%e %b %Y'`) echo `...` is usually redundant. In this case, it definitely is. You only need: today_day=$(date

Re: Passing paths with spaces from one command to another

2009-03-10 Thread Greg Wooledge
On Tue, Mar 10, 2009 at 02:31:06PM +0200, Angel Tsankov wrote: What if the second command is a function defiend in a shell script, or a bash built-in command? I assume this is related to Mike's earlier answer of: find . -print0 | xargs -0 ls You can use a while read loop: find .

Re: delete elements from an array...

2009-03-11 Thread Greg Wooledge
On Tue, Mar 10, 2009 at 03:21:38PM -0400, Chris F.A. Johnson wrote: while [ $n -lt ${#arra...@]} ] do case ${array2[$n]} in *$match*) array1[${#arra...@]}]=${array2[$n]} unset array2[n] Unsetting elements of array2 will create holes in the array, which means

Re: loop through records

2009-03-11 Thread Greg Wooledge
On Wed, Mar 11, 2009 at 01:11:51PM -0700, OnTheEdge wrote: array1=187431346 0323 mirrored 11866 187431346 0324 mirrored 11866 187431346 0325 mirrored 11866 187431346 0326 mirrored 11866 That's not an array. It's just a big string. array1=(187431346 0323 mirrored 11866 187431346 0324

Re: new redirection operator seems broken

2009-03-12 Thread Greg Wooledge
On Thu, Mar 12, 2009 at 05:21:04PM +0100, Andreas Schwab wrote: Still does not fix this case: $ echo 2 | wc -l 0 That looks like the correct output to me. When setting up a pipeline with redirections, the pipeline happens first. The manual says your example should be equivalent to

Re: new redirection operator seems broken

2009-03-12 Thread Greg Wooledge
On Thu, Mar 12, 2009 at 04:13:12PM -0400, Chet Ramey wrote: $ echo 2 | wc -l I wonder if I should modify it so the implicit 21 happens first, right after the pipe, so any user-specified redirections can override it. That doesn't seem that radical a change. Opinions? (I know what you

Re: Bash-4 breaks $(command) syntax on FreeBSD

2009-03-13 Thread Greg Wooledge
On Thu, Mar 12, 2009 at 05:05:33PM -0400, Gerard wrote: #!/usr/bin/env bash if $(which gpg2); then printf gpg2 located fi The behavior of which(1) is not reliable across platforms. Since you're already using bash, you should consider using one of the bash builtins instead: if command

Re: Creating directories with sticky bit set

2009-03-13 Thread Greg Wooledge
On Thu, Mar 12, 2009 at 07:40:58PM -0700, Ian Kelling wrote: mkdir also has the -m argument, so you could do mkdir -m 1755 dir Ah, clever. Then: mkdir() { command mkdir -m $(printf '%o\n' $((01777 - $(umask $@ } This still doesn't address the original poster's concerns if, for example,

Re: Creating directories with sticky bit set

2009-03-13 Thread Greg Wooledge
On Fri, Mar 13, 2009 at 11:40:58AM -0400, Dave Rutherford wrote: --- building $ gcc -fPIC -c -Wall sticky.c -o sticky.o $ gcc -shared sticky.o -ldl -lstdc++ -o sticky.so --- running $ export LD_PRELOAD=$PWD/sticky.so:$LD_PRELOAD --- for long-term use, add to bash startup files How

Re: String Concatenation with $'\NNN' Error

2009-03-16 Thread Greg Wooledge
On Sun, Mar 15, 2009 at 07:21:06AM -, t...@accesslab.com wrote: This command sequence concatenates a text string with a $'\NNN' string producing an error: shopt -s extglob; x=hello$'\179'; echo ${x//+([^[:print:]])/?} EXPECTED RESULT IS - hello? HOWEVER,

declare -c not documented

2009-03-19 Thread Greg Wooledge
The -c option for declare (new in bash 4.0) is not mentioned in either the man page or the help declare text.

Re: using mapfile is extreamly slow compared to oldfashinod ways to read files

2009-03-26 Thread Greg Wooledge
On Thu, Mar 26, 2009 at 08:53:50AM +0100, Lennart Schultz wrote: I have a bash script which reads about 25 lines of xml code generating ... mapfile file for i in ${mapfi...@]} do line=$(echo $i) # strip leading blanks case $line in done With this change the job now

Re: using mapfile is extreamly slow compared to oldfashinod ways to read files

2009-03-27 Thread Greg Wooledge
On Thu, Mar 26, 2009 at 05:59:14PM -0400, Chris F.A. Johnson wrote: Chet, how about an option to mapfile that strips leading and/or trailing spaces? Another useful option would be to remove newlines. It already has the latter: -tRemove a trailing newline from

Re: how to pass arguments with space inside?

2009-04-10 Thread Greg Wooledge
On Fri, Apr 10, 2009 at 12:02:56AM -0700, lehe wrote: The reason why I don't use $@ is that the arguments to the bash script is not completely those for the executable. Some of them are just arguments only to the bash script. So actually the script is like So you need to build up an *array* of

Re: possible bash 4.0.10 bug: command substitution in PROMPT_COMMAND

2009-04-10 Thread Greg Wooledge
On Thu, Apr 09, 2009 at 05:12:13PM -0400, Jared Yanovich wrote: Specifically, I use this output of a command in my prompt (sorry to offend anyone who finds that ridiculous), so it would be nice to have the old functionality back if possible. You can do: PS1='$(your command) other stuff here'

Re: Silent errors in process substitution

2009-04-15 Thread Greg Wooledge
On Wed, Apr 15, 2009 at 02:46:45PM +0200, Anakim Border wrote: is there any way to notice commands exiting with a non-zero status inside a process substitution? For example: $ cat (exit 1) ignores the exit status of exit: The whole point of the process substitution syntax is that it

Re: set the PS1 env with SGR cause problem

2009-04-17 Thread Greg Wooledge
On Fri, Apr 17, 2009 at 05:45:33PM +0800, tianlijian wrote: 1. add the export PS1='[\e[1;34m\W\e[0m]\$ to /etc/profile or ~/.bash_profile . You need to put \[ and \] (literally) around escape sequences in your prompt that don't move the cursor. In your case: PS1='[\[\e[1;34m\]\W\[\e[0m\]]\$

Re: Fails to build on HP-UX 10.20

2009-04-21 Thread Greg Wooledge
On Fri, Apr 17, 2009 at 08:52:16AM -0700, Matt Kraai wrote: Using nm, I found that _ was undefined in siglist.o. If I include bashintl.h in siglist.c, the problem is fixed. Yeah, I reported this exact problem a couple months ago, with the exact same fix. Good luck getting it incorporated into

Re: Testing standard output and exit statuses from commands in a pipe

2009-04-27 Thread Greg Wooledge
On Mon, Apr 27, 2009 at 05:02:26PM +0300, Angel Tsankov wrote: I'd like to pipe the output from a command, say A, to another command, say B, then check if both commands completed successfully (i.e.with exist status 0) PIPESTATUS An array variable (see Arrays below)

Re: grep remove no such file or directory

2009-05-06 Thread Greg Wooledge
On Wed, May 06, 2009 at 04:03:51PM +0200, Roman Rakus wrote: On 05/06/2009 02:14 PM, cseguino wrote: $ find . | xargs grep -v No such file or directory | grep StateRB grep: ./Tiger/codebase/netmarkets/jsp/ext/eurocopter/tiger/change/.svn/text-base/Copy: No such file or directory

Re: best indirect assign of scalar and array variables

2009-05-07 Thread Greg Wooledge
On Wed, May 06, 2009 at 04:53:27PM -0700, J. Greg Davidson wrote: What's the best way to update a variable indirectly, e.g. when its name is passed to an update function? http://mywiki.wooledge.org/BashFAQ/006

Re: Is this exploitable?

2009-05-11 Thread Greg Wooledge
On Mon, May 11, 2009 at 10:35:18AM +1000, Jon Seymour wrote: I am trying to parse untrusted strings and represent in a form that would be safe to execute. printf %q cmd=echo for a in $@ do cmd=$cmd '${a/\'/''}' done echo $cmd eval $cmd http://mywiki.wooledge.org/BashFAQ/050 - I'm

Re: Is there any mutex/semaphore mechanism in shell scripts?

2009-05-21 Thread Greg Wooledge
On Wed, May 20, 2009 at 12:34:42PM -0700, jjjaime wrote: FUNCTION_1 FUNCTION_2 FUNCTION_3 So, to speed up the execution of the script, I want FUNCTION_1 and FUNCTION_2 in parallel. But the script fails when FUNCTION_2 ends before FUNCTION_1. Why? Is there any mechanism for

Re: bash script error in array definition.

2009-05-27 Thread Greg Wooledge
On Wed, May 27, 2009 at 03:33:10AM -0700, straygrey wrote: Please tell me what is wrong with the following line that I have in a bash script:- [code] TODAYDATE=`date +%Y%m%d` declare -a FiLeS=( $TODAYDATE.TeleformDB.tar.bz2 $TODAYDATE.TeleformDB2.tar.bz2 ) [/code] When I run it I get:-

Re: Regex matching oddity (bug, or 'unexpected feature' or...?)

2009-05-28 Thread Greg Wooledge
On Thu, May 28, 2009 at 12:58:10PM -0700, Linda Walsh wrote: operator caused a failure in matching. I.e.: if [[ $Var=~+([:digit:]) ]] ; then ... worked. No, this is incorrect. You need spaces around the =~ so that it's parsed as three separate things, rather than one thing. Your code

Re: Using unset to destroy array elements doesn't work with 'nullglob' set

2009-06-05 Thread Greg Wooledge
On Fri, Jun 05, 2009 at 08:35:15AM -0700, Francis Moreau wrote: unset foo[0] This is a problem in your script, unfortunately. Even without nullglob, this can still fail if you happen to have a file named foo0 in your current working directory, which would be matched as a glob. For total

Re: feature request: more complete set -e

2009-06-29 Thread Greg Wooledge
On Mon, Jun 29, 2009 at 12:45:29AM +0200, Marc Weber wrote: echo `expr $var - 1` I think that this is bad. expr should do some calculation. If the calculation fails (eg devision by zero) the return value should be non zero. You'd think so, but alas, the people who made expr(1) had a

Re: feature request: more complete set -e

2009-06-30 Thread Greg Wooledge
On Tue, Jun 30, 2009 at 09:58:45PM +0200, Marc Weber wrote: How is this done? CHK0=test $? == 0 my_important_task; $CHK0 || exit 1 You'd need single quotes instead of double there. (And == is illegal in Bourne/POSIX shell test commands; only bash tolerates it.) You could also use a

Re: $\n doesn't get expanded between double-quotes

2009-07-06 Thread Greg Wooledge
On Fri, Jul 03, 2009 at 01:01:47PM -0400, Chris F.A. Johnson wrote: NL=$'\n' string=This is a$NLmulti-line$NLstring Of course you would need curly braces for that. NL=$'\n' string=This is a${NL}multi-line${NL}string

Re: Possible Feature Requests (unsource, exchange)

2009-07-07 Thread Greg Wooledge
On Tue, Jul 07, 2009 at 08:16:50PM +0200, Christopher Roy Bratusek wrote: unsource: the opposite of source (while source is making functions publically available, unsource would remove them) You can unset -f a function. You could source a script-file that contains a bunch of unset -f foo

Re: Possible Feature Requests (unsource, exchange)

2009-07-08 Thread Greg Wooledge
# Usage: exchange varname1 varname2 exchange() { local tmp [[ $1 = *[^[:alnum:]_]* || $1 = [0-9]* ]] { echo Naughty naughty 2; return 1; } [[ $2 = *[^[:alnum:]_]* || $2 = [0-9]* ]] { echo Naughty naughty 2; return 1; } eval tmp=\$$1 eval $1=\$$2

Re: [OT] regarding 'time' builtin

2009-07-20 Thread Greg Wooledge
On Fri, Jul 17, 2009 at 06:42:03PM -0400, Chris Jones wrote: Sometimes I wonder if Greg is a real person.. not a smart program that can generate the correct answers to all the questions you had about bash utilization - and may have been too shy to ask. Either I'm a real person, or I'm a brain

Re: Help with script - doesn't work properly from cron

2009-07-20 Thread Greg Wooledge
On Fri, Jul 17, 2009 at 02:53:21PM -0700, Erik Olof Wahlstrom wrote: #!/bin/bash BACKUP_DIR=/media/disk/AUTOMATED_BACKUPS/DB_DAILY CURRENT_DIR=$BACKUP_DIR/`date +%d` # See how you call date here without an explicit path? That's good. DATABASES=$(/usr/bin/mysql -uUsername -pPassword -Bse

Re: time seg fault

2009-07-23 Thread Greg Wooledge
On Thu, Jul 23, 2009 at 09:59:48AM -0400, Justin Williams wrote: Unfortunately, if I try to strace it (strace time ls), I get command not found. ''strace time ls'' will try to run the external command ''time'' which apparently you haven't got installed. (Which is probably good in this case, as

Re: Error with file descriptor

2009-08-03 Thread Greg Wooledge
On Sat, Aug 01, 2009 at 07:36:36PM +0200, Aljosha Papsch wrote: ModManager() { ClearFiles -4 echo zenity --list --window-icon=\${run_path}icon.png\ --width=\650\ --height=\350\ --title=\${modmanager[${lang}]}\ --text=\${RegMods[${lang}]}:\ --column=\${no[${lang}]}\

Re: Bash does not read up the whole script which it is currently executing

2009-08-04 Thread Greg Wooledge
On Tue, Aug 04, 2009 at 08:23:16AM -0700, John Reiser wrote: On 08/04/2009 12:48 AM, fam...@icdsoft.com wrote: The problem is that Bash does not read up the whole script which it is currently executing. As a result of this, if we update the script file with a newer

Re: wget command with simple url makes bash crash

2009-08-26 Thread Greg Wooledge
On Tue, Aug 25, 2009 at 02:40:24PM +0200, Oskar Hermansson wrote: wget http://www.kohanaphp.com/download?modules%5Bauth%5D=Authvendors%5Bmarkdown%5D=Markdownlanguages%5Ben_US%5D=en_USformat=zip If the command is placed in a file instead, the file is successfully downloaded: wget

Re: manpage note? weird strings that appear to be equal but create haywire comparisons?

2009-08-26 Thread Greg Wooledge
On Wed, Aug 26, 2009 at 04:36:42PM +0300, Pierre Gaston wrote: Thanks, I agree with that, I'm sorry I should have been more explicit, what was not clear to me was where this special role of the \ is explained, Because if you use literals [[ something = \* ]] is the same as [[ something = * ]]

Re: how to keep newlines in ``

2009-08-26 Thread Greg Wooledge
On Wed, Aug 26, 2009 at 03:04:16PM -0400, Sam Steingold wrote: foo=`ls` echo $foo echo $foo

Re: mysqldump usage in bash

2009-08-28 Thread Greg Wooledge
On Thu, Aug 27, 2009 at 06:13:38AM -0700, Arenstar wrote: temp=mysqldump -h $DBSource -u $USER -p$PASS $DB $TABLE --where='$Field $VarStart AND $Field $VarEnd' $TABLE$DumpName exec $temp The obvious problem here is that you want the last to be treated as a redirection operator.

Re: mysqldump usage in bash

2009-08-28 Thread Greg Wooledge
On Fri, Aug 28, 2009 at 07:06:52AM -0700, Arenstar wrote: What effects can eval have? that i am unaware of. In fact ive never used eval before, it just wasnt neccessary.. Thank you for your interesting reply query=mysqldump -h $DBSource -u rx -p $DB $TABLE --where '$Field

Re: ulimit and ssh?

2009-09-08 Thread Greg Wooledge
On Tue, Sep 08, 2009 at 11:39:02AM -0700, peter360 wrote: Thanks for the explanation. So my understanding of the way ssh works is still incorrect. I am confused about at which point the two parameters, -c and ulimit -a were converted into three, -c, ulimit, and -a. I guess I need to read

Re: redirection after braced block

2009-10-05 Thread Greg Wooledge
On Mon, Oct 05, 2009 at 07:55:33PM +0200, clemens fischer wrote: { ... a number of commands } 21 | ${prog_log} ${logfile} yeah ok, but the commands really are not executed. I have an option dry-run in the script, which sets prog_log=true. Then there are a bunch of verbose

Re: ${!vname} not documented

2009-10-06 Thread Greg Wooledge
On Tue, Oct 06, 2009 at 03:25:31AM -0400, Mike Frysinger wrote: On Tuesday 06 October 2009 01:39:56 Mikel Ward wrote: It would be more obvious if it had a paragraph directly below ${parameter} saying something like: ${!name} Indirect expansion. name is expanded to

Re: Cannot form valid test expressions that involve brackets as string comparison targets

2009-10-08 Thread Greg Wooledge
On Wed, Oct 07, 2009 at 08:07:19PM +1030, Lyall Pearce wrote: Description: Cannot form expressions which involve left or right brackets. Parentheses? Repeat-By: basePic=(2008-04) if [ ${basePic:0:1} = '(' -a ${basePic:4:1} = ')' ] then echo Got brackets

Re: Sed Question

2009-10-14 Thread Greg Wooledge
On Wed, Oct 14, 2009 at 12:24:30PM -0600, Bob Proulx wrote: Pierre Gaston wrote: Please consider asking in a sed mailing list like: http://sed.sourceforge.net/#mailing or maybe in the usenet group comp.unix.shell I would think help-gnu-ut...@gnu.org would be the better place to ask for

Re: bash reads on device when it shouldn't...

2009-10-23 Thread Greg Wooledge
On Thu, Oct 22, 2009 at 06:47:43PM +, K??rlis Repsons wrote: I've set up a system, which has some disks, that are not always used, but are always mounted. OS and program files are all in other place and the only program, which still reads some blocks (echo 1 /proc/sys/vm/block_dump),

Re: OT: Getting MySQL fields with embedded spaces into array

2009-10-28 Thread Greg Wooledge
On Wed, Oct 28, 2009 at 06:04:00AM -0400, Gerard wrote: COM_LINE=-u${SQL_USER} -p${SQL_PASSWORD} -h ${HOST} ${NO_COLUMN_NAME} table=MyTable DECLARE_STATEMENTS=($(mysql ${COM_LINE} -i -euse ${DB}; SELECT defaults FROM ${table} WHERE 1;)) You're populating an array with each word (not each

Re: [OT] Re: how to start in overwrite-mode

2009-10-28 Thread Greg Wooledge
On Wed, Oct 28, 2009 at 02:00:53PM +, Stephane CHAZELAS wrote: I can understand it. I was more curious about the origins. After all, that breaks Bourne backward compatibility (in a shell called Bourne-again shell) Bourne shell has no functions at all. Has there be historical versions of

Re: OT: Getting MySQL fields with embedded spaces into array

2009-10-29 Thread Greg Wooledge
On Thu, Oct 29, 2009 at 11:49:11AM -0400, Gerard wrote: Are you sure? Using: IFS=$(echo) seems to set IFS to a newline here. imadev:~$ IFS=$(echo) imadev:~$ printf %s $IFS | od -t x1 000 imadev:~$ printf \n | od -t x1 000a 001 imadev:~$ echo ${#IFS} 0 imadev:~$ unset IFS Also,

Re: value too great for base (error token is 0008)

2009-11-04 Thread Greg Wooledge
On Tue, Nov 03, 2009 at 05:37:45PM -0700, Bob Proulx wrote: Dobromir Romankiewicz wrote: bash: 0008: value too great for base (error token is 0008). Numbers with leading zeros are read as octal constants. Octal is composed of '0' through '7'. The number '8' is too large to be an octal

4.0 patch 25 breaks older gcc

2009-11-11 Thread Greg Wooledge
make[1]: Entering directory `/var/tmp/bash-4.0/lib/glob' rm -f glob.o /net/appl/gcc-3.3/bin/gcc -c -DHAVE_CONFIG_H -DSHELL -I. -I../.. -I../.. -I../../include -I../../lib -DHPUX -g -O2 glob.c glob.c:1026:69: missing terminating ' character make[1]: *** [glob.o] Error 1 make[1]: Leaving

siglist.c missing #include bashintl.h

2009-11-11 Thread Greg Wooledge
/net/appl/gcc-3.3/bin/gcc -L./builtins -L./lib/readline -L./lib/readline -L./lib/glob -L./lib/tilde -L./lib/malloc -L./lib/sh-g -O2 -o bash shell.o eval.o y.tab.o general.o make_cmd.o print_cmd.o dispose_cmd.o execute_cmd.o variables.o copy_cmd.o error.o expr.o flags.o jobs.o subst.o

4.0 core dump from printf -v foo %s bar

2009-11-11 Thread Greg Wooledge
The other two messages I sent today were just things I encountered while bringing my bash 4.0 up to the current patch level. This is the real problem I've been chasing. imadev:/var/tmp/bash-4.0$ bash-3.1.17 -c 'printf -v foo %s bar' imadev:/var/tmp/bash-4.0$ bash-4.0.10 -c 'printf -v foo bar'

Re: 4.0 core dump from printf -v foo %s b

2009-11-12 Thread Greg Wooledge
On Wed, Nov 11, 2009 at 09:41:29PM -0500, Chet Ramey wrote: If your version of vsnprintf doesn't behave like that, I claim it's a bug. The Posix and C standards explicitly allow the buffer to be NULL if the size argument is 0, and guarantee that no data will be written in this case. Thanks

[PATCH] Re: 4.0 core dump from printf -v foo %s b

2009-11-12 Thread Greg Wooledge
On Thu, Nov 12, 2009 at 02:37:58PM -0500, Chet Ramey wrote: I try to write to the current (well, ten-year-old) standards. The replacement in lib/sh/snprintf.c behaves as C99 specifies; you might try using it by #undefing HAVE_VSNPRINTF and HAVE_SNPRINTF in config.h. Ah, wonderful. I wasted a

Re: bash40-011 patch can't be applied cleanly

2009-11-19 Thread Greg Wooledge
On Wed, Nov 18, 2009 at 06:54:01PM -0800, Sergei Steshenko wrote: My script was applying patches from 'bash-4.0-patches' directory, not from 'bash-4.0' one, and maybe this was my mistake. Yes. You should always be in the source directory you're patching, when you apply a patch. The only

Re: Bash 4 and ECHOCTL

2009-11-23 Thread Greg Wooledge
On Thu, Nov 19, 2009 at 06:32:49PM +0100, Joachim Schmitz wrote: In siglist.c the compiler complained bitterly about having to convert the reseult of _() into a char * (sometimes comming from int, somtimes coming from const char *) My nasty workaround: The correct fix for that one is to

Re: sudo: command: not found

2009-11-23 Thread Greg Wooledge
On Sun, Nov 22, 2009 at 06:14:56PM +0800, wrote: run the command drcomd ,successful! but run command sudo drcomd ,return sudo : drcomd: command not found Not really a bash bug. under both (fedora)the PATH is

Re: printf %q and $'...'

2009-11-25 Thread Greg Wooledge
On 25 Nov 2009, at 08:19, Antonio Macchi wrote: Hi, I'm using older bash 3.2.39, so please forgiveme if in your newer bash this issue does not arise. On Wed, Nov 25, 2009 at 08:25:00AM +0100, Maarten Billemont wrote: As for NUL out outputting anything in your result, the cause is

Re: printf %q and $'...'

2009-11-25 Thread Greg Wooledge
On Wed, Nov 25, 2009 at 02:35:51PM +0100, Antonio Macchi wrote: it sounds strange, beacuse $ find . -print0 | while read -d $'\x00'; do touch $REPLY; done works fine. but if I try to output $'\x00', I can't. There's a lot going on here, so I'll try to cover it as best I can. When you

Re: IFS handling and read

2009-11-30 Thread Greg Wooledge
On Mon, Nov 30, 2009 at 11:46:03AM +0100, Lhunath (Maarten B.) wrote: Don't use pipelines to send streams to read. Use file redirection instead: Instead of ''command | read var'' Use ''read var (command)'' I hardly see a need to change the existing implementation. Or for the original

Re: ( error

2009-11-30 Thread Greg Wooledge
On Sat, Nov 28, 2009 at 02:57:45PM +0100, Antonio Macchi wrote: but, if you don't have hd (hexdump) how can you see the content of a, for example, strange file i mean $ ls -l total 0 -rw-r--r-- 1 user1 user1 0 2009-11-28 14:56 ? $ hd (ls) 09 0a

Re: ( error

2009-11-30 Thread Greg Wooledge
On Sat, Nov 28, 2009 at 02:18:37PM +0100, Antonio Macchi wrote: $ hd (echo -en \\0{0..3}{0..7}{0..7}) As for this, I wonder if you understand how bash handles this. I know it certainly wasn't obvious to me! Due to the way the parsing is done, the brace expansions inside the proces substitution

Re: operators available in bash versions

2009-11-30 Thread Greg Wooledge
On Mon, Nov 30, 2009 at 11:15:38AM -0500, Mike Frysinger wrote: On Monday 30 November 2009 06:12:35 Gerard wrote: I need to know if $( also works on Bash 4. it's been around for pretty much all time. bash-2 had it for sure, and that is ancient. It doesn't exist in bash 1.14.7, which

Re: IFS handling and read

2009-11-30 Thread Greg Wooledge
On Mon, Nov 30, 2009 at 04:21:33PM +, Marc Herbert wrote: Chris F.A. Johnson a écrit : Why should it be the last element of a pipeline that is executed in the current shell and not the first? Because that's POSIX' choice? Because that's what Korn shell does. (But not pdksh,

Re: operators available in bash versions

2009-11-30 Thread Greg Wooledge
On Mon, Nov 30, 2009 at 12:35:32PM -0500, Mike Frysinger wrote: On Monday 30 November 2009 12:12:17 Greg Wooledge wrote: On Mon, Nov 30, 2009 at 11:15:38AM -0500, Mike Frysinger wrote: On Monday 30 November 2009 06:12:35 Gerard wrote: I need to know if $( also works on Bash 4

Re: Command substitution reduce spaces even in strings

2009-12-08 Thread Greg Wooledge
On Tue, Dec 08, 2009 at 02:01:23PM +0100, ma...@fiz15.jupiter.vein.hu wrote: $ echo $(echo 'alfa beta') 'alfa beta' Instead of 'alfa beta' with double space. echo $(echo 'alfa beta')

Re: best way to test for empty dir?

2009-12-10 Thread Greg Wooledge
On Thu, Dec 10, 2009 at 05:31:20PM +, Marc Herbert wrote: Does anyone know a more elegant way to check for file existence? Something that does not fork a subshell. And is also more readable maybe. And is obviously not much longer. shopt -s nullglob files=(*) if (( ${#files[*]} == 0 ));

Re: best way to test for empty dir?

2009-12-10 Thread Greg Wooledge
On Thu, Dec 10, 2009 at 05:37:04PM -0200, Matias A. Fonzo wrote: Maybe you want the Chris F.A Johnson's implementation [1]: set -- /tmp/emptydir/* [[ -f $1 ]] echo non-empty || echo empty; References: [1] http://www.issociate.de/board/goto/866027/checking_if_a_directory_is_empty.html

Re: best way to test for empty dir?

2009-12-11 Thread Greg Wooledge
On Fri, Dec 11, 2009 at 01:09:09PM +0100, Antonio Macchi wrote: this could be another way to accomplish this empty_dir() { eval test \ $1/* \ == \ $1/* \; } (excluding invisible files...) This one also has the problem of failing if the directory contains a single file named '*'. It

Re: best way to test for empty dir?

2009-12-11 Thread Greg Wooledge
On Fri, Dec 11, 2009 at 04:16:13PM +, Marc Herbert wrote: In case anyone is interested my winner (so far) is: exists() { [ -e $1 -o -L $1 ] } if exists foo/*; then for f in foo/*; do ... done fi What if there's a subdirectory or something and you'd like to skip it?

Re: Bash-4.1-rc1 available for FTP

2009-12-22 Thread Greg Wooledge
On Tue, Dec 22, 2009 at 08:46:14AM -0500, Chet Ramey wrote: The first release candidate of bash-4.1 is now available with the URL ftp://ftp.cwru.edu/pub/bash/bash-4.1-rc1.tar.gz The syslog feature (in config-top.h) appears to be enabled by default. This is quite shocking

Re: Bash-4.1-rc1 available for FTP

2009-12-22 Thread Greg Wooledge
On Tue, Dec 22, 2009 at 02:23:47PM -0500, Mike Frysinger wrote: On Tuesday 22 December 2009 08:46:14 Chet Ramey wrote: The first release candidate of bash-4.1 is now available with the URL top level Makefile.in is missing pathnames.h dependency info for builtins/evalstring.o and

Re: $(pwd) != $(/bin/pwd)

2010-01-05 Thread Greg Wooledge
On Mon, Jan 04, 2010 at 01:25:50PM +, Stephane CHAZELAS wrote: da...@thinkpad ~/foo $ echo $PWD /home/darkk/foo Well, if I read http://www.opengroup.org/onlinepubs/9699919799/utilities/pwd.html correctly, bash pwd should output /home/darkk/bar in that case as $PWD does *not* contain

Re: can't compile bash 4.1 under Solaris 8/9

2010-01-07 Thread Greg Wooledge
On Thu, Jan 07, 2010 at 12:22:12PM +0100, Yann Rouillard wrote: ./printf.def:175: error: conflicting types for 'vsnprintf' Maybe you could first send me the config.log/config.h generated on Solaris 8 so I can compare with mine ? It might be more useful to compare your stdio.h header file

Re: can't compile bash 4.1 under Solaris 8/9

2010-01-07 Thread Greg Wooledge
On Thu, Jan 07, 2010 at 09:03:19AM -0500, Chet Ramey wrote: *** ../bash-4.1/builtins/printf.def 2009-11-20 15:31:23.0 -0500 --- builtins/printf.def 2010-01-07 08:50:06.0 -0500 *** *** 173,177 #if !HAVE_VSNPRINTF ! extern int vsnprintf __P((char

Re: weird bash pipe behavior

2010-01-21 Thread Greg Wooledge
On Wed, Jan 20, 2010 at 07:34:35AM -0800, CptDpondo wrote: mencoder 21 | tr '\r' '\n' | grep -v -B 1 '^Pos' this eventually creates the correct output, but it's buffered until mencoder completes. I have no idea why; the tr command streams without buffering and I've used grep for years

Re: Any guide about writing my own bash built-in commands?

2010-02-01 Thread Greg Wooledge
On Sat, Jan 30, 2010 at 03:17:22PM +0100, Joachim Schmitz wrote: Clark J. Wang wrote: Hi all, I want to write my own built-in bash commands but I cannot find any info about that in bash manual. Anyone has any idea? Have a look into the .def files in the builtins directory of bash's source

Re: Grepping an array in bash, odd/buggy behavior when using shopt and '!'

2010-02-03 Thread Greg Wooledge
On Tue, Feb 02, 2010 at 07:29:25PM -0800, Davey E wrote: FOO[3]=ABZ555 shopt -s extglob echo '${f...@]/#!(ABZ555)/}' results in: ${f...@]/#!(ABZ555)/} When run, I see: ${f...@]/#!(ABZ555)/} results in: 5 You are trying to use a substitution operator to perform matching, which is not what

Re: Error when script uses CRLF line endings w/ if stmt

2010-02-05 Thread Greg Wooledge
On Thu, Feb 04, 2010 at 11:54:51PM -0600, Evan Driscoll wrote: Why not make Bash consider \r\n a legitimate line ending? What possible reason could there be for treating carriage return characters as it does now? Well, the most literal reason is that the shebang (#!/program) line will not

Re: + vs. [^/]* - Regular Expression bug?

2010-02-11 Thread Greg Wooledge
On Tue, Feb 09, 2010 at 09:18:47PM -0800, DennisW wrote: * means zero or more characters. It found zero and stopped. You could do: [[ '/home/' =~ /([^/]*) ]]; echo ${BASH_REMATCH[1]} Oh, is he trying to get the first non-null component of a /-delimited pathname? I can never tell any

Re: process substitution and trailing file descriptors

2010-02-11 Thread Greg Wooledge
On Thu, Feb 11, 2010 at 03:04:30AM -0800, Ian wrote: The manual suggests I could move and close file descriptors with [n]digit- but I would need the equivalent of command1 (...)- Digit might very well mean (just a) digit but here the process substitution, of course, is replaced

Re: undefined reference to `__strtoll'

2010-02-11 Thread Greg Wooledge
On Thu, Feb 11, 2010 at 12:58:46PM -0500, Dave Moore wrote: Machine: hppa2.0w OS: hpux11.00 Compiler: gcc Bash Version: 4.1 Patch Level: 0 I don't have an HP-UX 11.00 machine to test on, but: I'm having trouble compiling bash on HP-UX 4.1. I can't figure out how to work around it.

Re: Is there a special variable for the directory where the script is in?

2010-02-12 Thread Greg Wooledge
On Fri, Feb 12, 2010 at 11:56:49AM +0100, Guillaume Outters wrote: I usually begin all my scripts with this beast: absolutiseScripts() { SCRIPTS=$1 ; echo $SCRIPTS | grep -q ^/ || SCRIPTS=`dirname $2`/$SCRIPTS ; } ; absolutiseScripts `command -v $0` `pwd`/. ; while [ -h $SCRIPTS ] ; do

Re: FWD: About Bash Script

2010-02-15 Thread Greg Wooledge
On Mon, Feb 15, 2010 at 10:20:05PM +0100, Mart Frauenlob wrote: From: Curt cain...@gmail.com What I want to do is simply if the destination file exists, instead it creates an index number and appends that to the name. If b.txt exists then a.txt will be renamed to b.txt.1, but if

Re: Variable getopts lost

2010-02-23 Thread Greg Wooledge
On Tue, Feb 23, 2010 at 08:30:16PM +0100, Daniel Bunzendahl wrote: if [ !$LSEITE ]; then You want: if [ ! $LSEITE ] There are probably more errors. This is just the line you mentioned in particular as not working.

Re: echo ^C

2010-02-23 Thread Greg Wooledge
On Tue, Feb 23, 2010 at 10:23:38PM +0100, Freddy Vulto wrote: Within the bash-completion testsuite, we're trying to synchronize in between test cases using the string ^C, output by bash on receiving a SIGINT. This works fine for bash = 4 (typing ^C is echoed as ^C), but on bash-3 typing ^C is

Re: echo ^C

2010-02-24 Thread Greg Wooledge
On Tue, Feb 23, 2010 at 05:23:00PM -0500, Chet Ramey wrote: That capability (readline echoing the key that generated a signal if the ECHOCTL bit was set with stty) was not added until bash-4.0. It's a settable variable in bash-4.1, so you may not want to rely on it. ... Ah, there it is. In

Re: Logically equivalent statements output different results. Suspect problem with 'pipe'.

2010-03-02 Thread Greg Wooledge
On Tue, Mar 02, 2010 at 03:41:36PM +0530, Kalidas Yeturu wrote: p=0; for lig in `cat a`; do cat b | while read i; do echo printing $p; ((p=$p+1)); done; done #outputs(I DO NOT EXPECT p TO BE RESET EACH TIME WHILE RUNS) printing 0 printing 1 printing 2 printing 0 printing 1

Re: Data piped to 'mapfile', 'readarray', 'read -a' shell builtins is ignored

2010-03-24 Thread Greg Wooledge
On Wed, Mar 24, 2010 at 04:10:41PM +0200, Pierre Gaston wrote: On Wed, Mar 24, 2010 at 12:43 AM, Rob Robason r...@robason.net wrote: $ ls -a | readarray# using the default MAPFILE array It's a faq, commands in a pipe are executed in a subshell and don't modify the parent shell.

Re: printf builtin: '*' broken in conversion spec field width and precision (e.g., %.*s)

2010-03-25 Thread Greg Wooledge
On Thu, Mar 25, 2010 at 03:32:25AM -0700, Rob Robason wrote: The printf builtin is broken in many variations of use of '*' (e.g., %.*s) in a printf conversion spec to set field width and precision from argument values. The use of '*' as a field width is not required by POSIX. According to

Re: manpage error-Arithmetic Evaluation of numbers with explicit base

2010-03-29 Thread Greg Wooledge
On Mon, Mar 29, 2010 at 02:22:35PM +0200, Thomas Bartosik wrote: Well OK, I understand. Still I think there should be a difference in the man page when it comes to brackets. When talking about arrays, the brackets are NOT an option but mandatory. That's correct. Referencing a specific element

Re: Bash sometimes cannot find aliases

2010-03-30 Thread Greg Wooledge
On Tue, Mar 30, 2010 at 02:36:59PM +0800, Clark J. Wang wrote: After some investigation I could stably reproduce this problem by following steps (tested with bash 3.1.17, 3.2.39 and 4.1.0): bash$ alias xx='echo 142857'### Make sure there isn't an external cmd named `xx' bash$ export

  1   2   3   4   5   6   7   8   9   10   >