Re: /dev/fd/62: No such file or directory

2014-03-28 Thread Greg Wooledge
On Fri, Mar 28, 2014 at 08:21:40AM -0700, Linda Walsh wrote: > What I'd prefer to see is that bash do what you say at > runtime, rather being limited to that choice at build time. If you require process substitution features in a script that may be executed when the OS is not fully booted, I

Re: /dev/fd/62: No such file or directory

2014-03-31 Thread Greg Wooledge
On Fri, Mar 28, 2014 at 06:14:27PM -0700, Linda Walsh wrote: > Does read varname <<<$(...) use process substitution? I wouldn't dare write it like that, because who knows how the parser will treat it. I'd write it this way: read varname <<< "$(...)" This is a command substitution and a here-str

Re: /dev/fd/62: No such file or directory

2014-04-02 Thread Greg Wooledge
On Wed, Apr 02, 2014 at 07:54:58AM +0300, Pierre Gaston wrote: > On Wed, Apr 2, 2014 at 6:04 AM, Linda Walsh wrote: > > Well don't know if it circumvents the /fd/62 prob > > yet (got a few places more to check & convert), > > but this seems to work for checking if a file > > or dir is empty: > > >

Re: jobs -p falsely reports the last background pid

2014-04-09 Thread Greg Wooledge
On Wed, Apr 09, 2014 at 12:43:40PM +0200, Håkon Bugge wrote: > This script never terminates: > -- > #!/bin/bash > > for P in `seq 5`; do > sleep 1& > done > > while true; do > usleep 2 > set foo `jobs -p` > LEFT=$# > LEFT=$

Re: jobs -p falsely reports the last background pid

2014-04-09 Thread Greg Wooledge
On Wed, Apr 09, 2014 at 02:16:22PM +0200, Håkon Bugge wrote: > That is not the issue. Try it out. Very well. I can confirm that this script does not terminate on HP-UX 10.20 under bash 4.3.8: #!/bin/bash set -m for x in 1 2 3 4 5; do sleep 1 & done while jobs=$(jobs -p) echo "jobs left: <$

Re: push cannot be redirected in 4.1.5

2014-04-30 Thread Greg Wooledge
On Wed, Apr 30, 2014 at 07:27:27AM -0700, Viktor Szépe wrote: > [root@szerver:/var/www:16:26:19:593] pushd zsolt-nezzan | cut -d' ' -f1 > /var/www/zsolt-nezzan pushd needs to operate on the current shell, rather than in a child process. When you use a pipeline, as you did here, each command in th

Re: push cannot be redirected in 4.1.5

2014-04-30 Thread Greg Wooledge
On Wed, Apr 30, 2014 at 04:39:28PM -0400, Chet Ramey wrote: > On 4/30/14, 4:34 PM, Viktor Szépe wrote: > > echo first $$ >&2 | bash -c 'echo second $$' > > first 30551 > > second 28057 > > > > but > > > > eval 'echo first $$' >&2 | eval 'echo second $$' > > first 30551 > > second 30551 > > $$ d

Re: push cannot be redirected in 4.1.5

2014-04-30 Thread Greg Wooledge
On Wed, Apr 30, 2014 at 02:04:02PM -0700, Viktor Szépe wrote: > I am surprised of these different values: > > echo "MAIN $BASHPID" ; echo "first $BASHPID" >&2 | echo "subshell $BASHPID" > MAIN 30551 > subshell 8514 > first 8513 > > Why neither side of the pipe has pid 30551? > Why are TWO new sub

Re: sourcing script file from inside a function doesn't work anymore

2014-05-12 Thread Greg Wooledge
On Sat, May 10, 2014 at 12:22:40PM +0200, thioroup8 wrote: > Now, I source it from inside a function: I obtain following error message: > bash: declare: tmp: not found > I think this problem raises in the particular case of involving array > variables definitions inside sourced bash script file...

Re: sourcing script file from inside a function doesn't work anymore

2014-05-12 Thread Greg Wooledge
On Mon, May 12, 2014 at 03:33:34PM +0200, Geir Hauge wrote: > Oddly, the quotes seem to matter; changing array='(x)' to array=(x) > makes it work... > > $ f() { source <(printf "declare -a array=(x); declare -p array\n"); }; f > declare -a array='([0]="x")' OK, this also happens on my system. In

Re: Bug when trapping exit from subshell

2014-05-19 Thread Greg Wooledge
On Mon, May 19, 2014 at 10:39:59AM -0700, Mark Ferrell wrote: > I'm sorry, but the lack of consistency still sounds like it is a bug > in bash. The behaviour I would expect is functionally equivalent to > 'do_cmd > /dev/null 2>&1 || err_handler'. Further more, this IS the > behaviour seen if the

Re: winch trap delayed until keypress

2014-05-22 Thread Greg Wooledge
On Thu, May 22, 2014 at 06:02:42AM -0700, Linda Walsh wrote: > This allows me to dynamically see what I'm doing when I resize a window > if I am going for a specific size (which happens usually after I've > expanded it for some reason, and am now trying to size it back down. fvwm2 (which I've been

Re: What is the difference between a newline and a semi-colon?

2014-05-30 Thread Greg Wooledge
On Fri, May 30, 2014 at 09:13:01AM -0600, Eric Blake wrote: > (I've seen ONE case where an alias can do things that a function cannot: > writing an alias for 'find' that temporarily inhibits globbing on the > arguments for JUST the find command - that has to be done via an alias, > because it depen

Re: Arithmetic + array allows for code injection

2014-05-30 Thread Greg Wooledge
On Fri, May 30, 2014 at 08:57:42PM +0300, Pierre Gaston wrote: > It doesn't seem right for code looking as innocent as $((a[$i])) or > $((a["$i"])) to allow running arbitrary commands for some value of i, that > are no even that clever: > > $ i='$( echo >&2 an arbitrary command )';: $((a["$i"]))

Re: Arithmetic + array allows for code injection

2014-06-02 Thread Greg Wooledge
On Fri, May 30, 2014 at 09:28:13PM -0500, Dan Douglas wrote: > The problem is most people don't realize how "variables" are evaluated. > Any time the shell needs to reference a variable, it takes a string > like: "arr[$foo]" and, if there's an index, the string within the index > gets processed for

Re: Arithmetic + array allows for code injection

2014-06-02 Thread Greg Wooledge
On Mon, Jun 02, 2014 at 03:08:17PM +0200, Andreas Schwab wrote: > Greg Wooledge writes: > > > imadev:~$ : $((a[$x])) > > bash: Mon Jun 2 08:06:39 EDT 2014: syntax error in expression (error token > > is "Jun 2 08:06:39 EDT 2014") > > > > There

Re: bash segfaults on EOF-delimited [^D] 'here-documents' (instead of aborting command?) when PS2 is not a static value (PS3 might have problems too)

2014-06-03 Thread Greg Wooledge
On Mon, Jun 02, 2014 at 06:02:31PM -0400, osirisgothra paradisim llc wrote: > GNU bash, version 4.3.11(1)-release (x86_64-pc-linux-gnu) The hardware and > operating system. > ubuntu@localhost:~$ PS2='$(echo "enter something>")' > ubuntu@localhost:~$ cat <<-EOF > enter something>here's some text >

Re: Inconsistent string comparison operators n and z

2014-06-09 Thread Greg Wooledge
On Mon, Jun 09, 2014 at 01:11:31PM +, Thibault, Daniel wrote: > Consider these lines: > > $ if [ -z `pgrep pname` ]; then echo "not r" ; else echo "r" ; fi > $ if [ ! -z `pgrep pname` ]; then echo "r" ; else echo "not r" ; fi > $ if [ -n `pgrep pname` ]; then echo "r" ; else echo "not r" ;

Re: Possible bug when combining Bash's process substitution with HERE-document?

2014-06-20 Thread Greg Wooledge
On Fri, Jun 20, 2014 at 12:00:02AM +0200, Tim Friske wrote: > While searching for an alternative I came up with the following code > which does not work when I have the "shopt -os errexit" command line > at the top of my script: > > read -d '' -r foobar < bla bla > BARFOO read returns "failure" b

Redirecting to /dev/stderr on Linux truncates files

2014-07-02 Thread Greg Wooledge
An IRC user initially reported this behavior, which is present in at least bash 4.0, 4.2 and 4.3 on Linux (but *not* on HP-UX): Redirection to /dev/stderr on platforms that have /dev/stderr as a part of the native file system is *not* equivalent to >&2 as the manual would seem to imply. This is t

Re: leading zeros ignored by perl, ksh. not bash

2014-07-23 Thread Greg Wooledge
On Wed, Jul 23, 2014 at 07:20:01AM +, maik.lied...@sungard.com wrote: > how we can declare hrs and min? > or can we disable the automatic change from decimal to octal? Strip the leading zeroes, or force base 10 with 10#$foo inside the math context. > TIME="08:09" Using all-caps variables is

Re: Code for :"Re: HERE document failed && Re: /dev/fd/62: No such file or directory"

2014-07-28 Thread Greg Wooledge
On Fri, Jul 25, 2014 at 04:44:27PM -0700, Linda Walsh wrote: > FWIW, this script DOES work interactively in normal operation. > > Just when the system is in pre-single-user state and not > much in the way of resources is available that it blows. Then you are attempting to use operating system fea

Re: Code for :"Re: HERE document failed && Re: /dev/fd/62: No such file or directory"

2014-07-29 Thread Greg Wooledge
On Tue, Jul 29, 2014 at 12:06:41PM -0700, Linda Walsh wrote: > Andreas Schwab wrote: > >You need a file descriptor for your memory storage. > --- > Why? A here-document is a redirection. All it does it change where stdin comes from. There has to be a place for file descriptor 0 to point to. This

Re: Code for :"Re: HERE document failed && Re: /dev/fd/62: No such file or directory"

2014-07-29 Thread Greg Wooledge
On Tue, Jul 29, 2014 at 10:21:36PM +0200, Angel wrote: > What surprises me is that the only use of here-docs (actually > here-strings) in your script are process substitutions: > > read out <<<$(declare -p "$var" ) > > while ... done <<<"$(get_net_IFnames_hwaddrs)" > > When it looks simpler to wri

Re: is this fixed in 4.3?

2014-07-31 Thread Greg Wooledge
On Wed, Jul 30, 2014 at 02:46:08PM -0700, Linda Walsh wrote: > I just noticed in the 4.2.45 I'm still running that when I > reset my local to standard (LC_ALL=C), it turned off > "vi mode" in my shell ops and turned on emacs mode. I cannot reproduce this. imadev:~$ bash-4.2 imadev:~$ echo $BASH_V

Re: read-only flag is lost for functions in sub shells

2014-07-31 Thread Greg Wooledge
On Thu, Jul 31, 2014 at 07:51:01AM -0700, Linda Walsh wrote: > Chet Ramey wrote: > >$ ./bash ./x24 > >4.2.47(4)-release > >foo = one > >foo = two > >$ cat ./x24 > >echo $BASH_VERSION > > > >foo=one > >readonly foo > >export foo > > > >./bash -c 'echo foo = $foo ; foo=two ; echo foo = $foo' > > Whe

Re: is this fixed in 4.3?

2014-07-31 Thread Greg Wooledge
On Thu, Jul 31, 2014 at 07:54:33AM -0700, Linda Walsh wrote: > Greg Wooledge wrote: > >On Wed, Jul 30, 2014 at 02:46:08PM -0700, Linda Walsh wrote: > >>I just noticed in the 4.2.45 I'm still running that when I > >>reset my local to standard (LC_ALL=C), it turned o

Re: bug? "type -P xxx" returns "xxx" that isn't executable...(or readable)

2014-08-01 Thread Greg Wooledge
at the shell will attempt, not what > is useful. the fact that it's not usable is irrelevant. > > if you want to see if it's executable, use `[ -x ... ]`. That does indeed seem to be the case. golem:~$ touch ~/bin/kumquat golem:~$ type kumquat kumquat is /home/greg/bin/k

Re: read-only flag is lost for functions in sub shells

2014-08-01 Thread Greg Wooledge
On Thu, Jul 31, 2014 at 04:45:20PM -0700, Linda Walsh wrote: > Also noticing broken-ness upon using "sudo" -- functions defined > at login are undefined: > > >typeset -f|grep titlebar > titlebar () > declare -fx titlebar Some implementations of sudo clear the environment before elevating privi

Re: bug? "type -P xxx" returns "xxx" that isn't executable...(or readable)

2014-08-01 Thread Greg Wooledge
On Fri, Aug 01, 2014 at 12:30:58PM -0700, Linda Walsh wrote: > Maybe I'm in the minority, but I think the type command is > *fundamentally*, used to look up commands -- things that are > executable. Returning something that isn't because it fits > some Faustian rules seems a bit perverse, no? Wel

Re: Segmentation fault bash 4.3.022

2014-08-11 Thread Greg Wooledge
On Tue, Aug 12, 2014 at 02:21:18AM +0800, lolilolicon wrote: > The following code segfaults when run by bash 4.3.022 > > set -E > shopt -s lastpipe > trap -- 'true' ERR > true | { true | false; } I could not reproduce this, on HP-UX or Linux. I tried from an interactive shell, just typin

Re: Segmentation fault bash 4.3.022

2014-08-12 Thread Greg Wooledge
On Tue, Aug 12, 2014 at 09:15:04AM -0400, Chet Ramey wrote: > On 8/11/14, 2:21 PM, lolilolicon wrote: > > The following code segfaults when run by bash 4.3.022 > > > > set -E > > shopt -s lastpipe > > trap -- 'true' ERR > > true | { true | false; } > > Here's a patch for those who would l

Re: change in behavior starting with bash-4.3_p14 and $@ in [[...]]

2014-08-13 Thread Greg Wooledge
On Wed, Aug 13, 2014 at 09:47:51AM -0400, Chet Ramey wrote: > On 8/12/14, 11:05 PM, Mike Frysinger wrote: > > foo=(0 0 0); [[ -z ${foo[@]#0} ]]; echo $? > Word splitting is > suppressed inside [[, so the array expands to a single word ("0 0 0"), the > 0s are removed, leaving " " That doesn't sou

Cannot trap INT in child of an interactive shell

2014-08-13 Thread Greg Wooledge
Bash 4.3.22, HP-UX. imadev:~$ child() { trap - INT; trap 'echo I got an INT; trap - INT; kill -INT $ BASHPID' INT; while true; do sleep 1; done; }; child & [1] 19116 imadev:~$ kill -INT 19116 imadev:~$ kill -INT 19116 imadev:~$ kill -TERM 19116 [1]+ Terminated child The manual says:

Script with set -m launched from interactive shell makes all ancestor shells die

2014-08-13 Thread Greg Wooledge
This was tested on bash 4.3.22 (HP-UX) and bash 4.2.37 (Linux). Create a script named foo with the following content: #!/bin/bash set -m while sleep 1; do :; done Make it executable, and type ./foo & at an interactive shell. You get your shell prompt back. You can press Enter as many times a

Re: Substring Expansion does not work as intended

2014-08-20 Thread Greg Wooledge
On Wed, Aug 20, 2014 at 03:05:48PM +0200, eckard.bra...@gmx.de wrote: > "If offset evaluates to a number less than zero, the value is used as > an offset from the end of the value of parameter." > > Repeat-By: > x="abcdef"; echo "${x:-2}" > Expected: ef > Got: abcdef

Re: Feature request: Add "import" built-in.

2014-08-25 Thread Greg Wooledge
On Sun, Aug 24, 2014 at 01:36:38PM +0200, Tim Friske wrote: > I currently emulate the behavior I seek for with the following function: > > function _import { > local -r file="$1" > set -- "${@:2}" > source "$file" "$@" > } How is this different from source, exactly? You're passing all of t

Re: Feature request: Add "import" built-in.

2014-08-25 Thread Greg Wooledge
On Mon, Aug 25, 2014 at 11:10:31PM +0800, lolilolicon wrote: > On Mon, Aug 25, 2014 at 8:04 PM, Greg Wooledge wrote: > > On Sun, Aug 24, 2014 at 01:36:38PM +0200, Tim Friske wrote: > >> I currently emulate the behavior I seek for with the following function: > >

Re: SEGFAULT if bash script make "source" for itself

2014-08-28 Thread Greg Wooledge
On Thu, Aug 28, 2014 at 11:49:02AM -0700, bogun.dmit...@gmail.com wrote: > So why I should got SIGSEGV instead of nice, detailed error message in > recursion? We can detect it? You can't detect that it's going to happen. You can only receive the SIGSEGV *after* it happens. We already have a conf

Re: need ability to tell if array is associative or not - bug?

2014-08-29 Thread Greg Wooledge
On Fri, Aug 29, 2014 at 03:07:40PM +0100, Jason Vas Dias wrote: > There seems to be no way of testing if an array variable is associative or not $ unset a b; declare -A a; a[1]=foo; b=(an array); declare -p a b declare -A a='([1]="foo" )' declare -a b='([0]="an" [1]="array")'

Re: need ability to tell if array is associative or not - bug?

2014-08-29 Thread Greg Wooledge
On Fri, Aug 29, 2014 at 04:45:30PM +0100, Jason Vas Dias wrote: > local value='1.0'; > The end result expression being evaluated: > ++ my_array=(['value']='1.0') > should never involve an arithmetic expression, > and should be valid regardless if the array is > associative or not . Your i

Re: need ability to tell if array is associative or not - bug?

2014-08-29 Thread Greg Wooledge
On Fri, Aug 29, 2014 at 05:19:03PM +0100, Jason Vas Dias wrote: > Aha! Yes, that was it . Thank you! > I wouldn't have expected expansion to occur for a name in single quotes. > > I still think it would be nice to have the ability to tell if an array has > been > declared associative or not. Wha

Re: nameref bug?

2014-09-02 Thread Greg Wooledge
On Sat, Aug 30, 2014 at 12:02:33PM +0800, lolilolicon wrote: > > #!/bin/bash > > declare var="hello world" > > declare -n ref > > ref=var > > echo $ref > > ref=var > > echo $ref > > > > --- output --- > > hello world > > var > Ah, LOL I think I need some sleep. This is not a bug. Sorry for all the

Re: nameref bug?

2014-09-02 Thread Greg Wooledge
On Wed, Sep 03, 2014 at 02:18:25AM +0800, lolilolicon wrote: > Indeed this seems worth adding to the Greg's Wiki! There is a *tiny* bit already written on this topic, but it's hidden deep inside FAQ 048: http://mywiki.wooledge.org/BashFAQ/048#The_problem_with_bash.27s_name_references Ormaaj also

Re: shebang length limits

2014-09-05 Thread Greg Wooledge
On Fri, Sep 05, 2014 at 08:09:40AM -0400, The Wanderer wrote: > What exactly is the limit on the length of a shebang line in an > executable script, when called from within bash? Shebangs are handled by the kernel, not by bash. For more details, Sven Mascheck's page is the best out there: http://

Re: in error messages, do not output raw non-printable characters to the terminal

2014-09-10 Thread Greg Wooledge
On Wed, Sep 10, 2014 at 01:32:18PM -0400, Steve Simmons wrote: > is a helluva lot more sensible than > >cd $LOG ># take actions here... >rm * Oh dear gods. That's madness. Never EVER do that. If the cd command fails for any reason, you will remove all the files in the wrong directo

Re: Not so useless use of cat

2014-09-15 Thread Greg Wooledge
On Fri, Sep 12, 2014 at 06:12:13PM -0600, Bob Proulx wrote: > (for i in file[12] ; do cat "$i" > /dev/stdout ; done) > both > > > $ cat both > > second > > Because the >/dev/stdout truncates the output. It writes the first. > Then the second one truncates the file and then writes the second.

Re: Not so useless use of cat

2014-09-16 Thread Greg Wooledge
On Tue, Sep 16, 2014 at 09:03:20AM +0200, Ralf Goertz wrote: > Actually things are more complicated. I do need the /dev/stdout part. I > obiously don't have the problem with `cat' but with some other program > $ for i in file[12] ; do program -i "$i" -o /dev/stdout ; done > outfile It's important

Re: Base conversion within Base

2014-09-17 Thread Greg Wooledge
On Tue, Sep 16, 2014 at 02:45:42PM -0400, IT1 Stuart Blake Tener, USNR wrote: > It is rather simplistic to perform a conversion of a number from any > base to base 10 in bash using such construction as: echo $((36#AB1CDE1)) > > However, the greatness of the foregoing notwithstanding, it would be

Re: Base conversion within Base

2014-09-17 Thread Greg Wooledge
On Wed, Sep 17, 2014 at 08:46:28AM -0400, IT1 Stuart Blake Tener, USNR wrote: > In as much as bc only tells you which position in the string > "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ" it corresponds too. > > Useless and incomplete without a script to complete it! Thus, a bug > worthy of being re

Re: Not so useless use of cat

2014-09-18 Thread Greg Wooledge
On Thu, Sep 18, 2014 at 07:26:33AM -0600, arn...@skeeve.com wrote: > I'm finding that modern systems have pretty much the union of things > that I need, and also that the older ones that don't simply aren't > in use anymore. E.g., do you still need to support SunOS 4.1.x? Ultrix? > OSF/1? Irix? W

Re: Issues with exported functions

2014-09-24 Thread Greg Wooledge
On Thu, Sep 25, 2014 at 03:44:23AM +0800, lolilolicon wrote: > Otherwise, if this feature is going to stay (can anyone enlighten me why > it's useful?), please document it explicitly. First, it is documented: Functions may be exported so that subshells automatically have them defined

Re: Issues with exported functions

2014-09-24 Thread Greg Wooledge
On Thu, Sep 25, 2014 at 03:54:19AM +0800, lolilolicon wrote: > I think almost as severe as CVE-2014-6271 is that it's still possible to > mask commands in a bash script by changing it's environment. > > For example, true='() { false;}' or grep='() { /bin/id;}' ... I'm still waiting for someone to

Re: Bash-4.3 Official Patch 25

2014-09-25 Thread Greg Wooledge
On Thu, Sep 25, 2014 at 06:02:11AM -0700, gnu.bash.bug wrote: > Hi, > > This patch does not seem to work on HP-UX: Worked for me on 10.20. > > $ /usr/bin/env x='() { :;}; echo vulnerable' bash -c 'echo hello' > vulnerable > hello imadev:~$ uname -a HP-UX imadev B.10.20 A 9000/785 2008897791 tw

Re: Bash-4.3 Official Patch 25

2014-09-25 Thread Greg Wooledge
On Thu, Sep 25, 2014 at 02:50:03PM +0100, Jason Vas Dias wrote: > But now there is an issue - bash seems to lose its idea of stdout / stderr > being > a terminal within read loops, as illustrated by this test script (/tmp/t.sh): > > > #!/bin/bash > tty > echo $'1\n2' > test.list; > while read l

Re: Bash-3.1 Official patch 10

2006-02-22 Thread Greg Schafer
be accepted by older Bash versions. Do think problem lies with this Bash patch or with test case? Thanks Greg -- http://www.diy-linux.org/ ___ Bug-bash mailing list Bug-bash@gnu.org http://lists.gnu.org/mailman/listinfo/bug-bash

Re: Bash-3.1 Official patch 10

2006-02-24 Thread Greg Schafer
er Bash versions. Do you think problem lies with this Bash patch or with test case? Thanks Greg -- http://www.diy-linux.org/ ___ Bug-bash mailing list Bug-bash@gnu.org http://lists.gnu.org/mailman/listinfo/bug-bash

lines do not wrap properly in a new window

2006-05-26 Thread Greg Wooledge
Configuration Information [Automatically generated, do not change]: Machine: hppa2.0 OS: hpux10.20 Compiler: /net/appl/gcc-3.3/bin/gcc Compilation CFLAGS: -DPROGRAM='bash' -DCONF_HOSTTYPE='hppa2.0' -DCONF_OSTYPE='hpux10.20' -DCONF_MACHTYPE='hppa2.0-hp-hpux10.20' -DCONF_VENDOR='hp' -DLOCALEDIR='/

[PATCH] Robustify configure check for /dev/fd

2006-08-13 Thread Greg Schafer
Hi This issue was reported earlier but with apparently no response: http://lists.gnu.org/archive/html/bug-bash/2006-05/msg00018.html When su'd to a non-root user under Linux the configure check fails: checking whether /dev/fd is available... absent Here is a suggested patch as per the foll

functions and set -e

2006-08-29 Thread Greg Schafer
part of a `&&' or `||' list," The problem appears to be specific to functions. Is this a bug? Thanks Greg ___ Bug-bash mailing list Bug-bash@gnu.org http://lists.gnu.org/mailman/listinfo/bug-bash

Re: functions and set -e

2006-08-29 Thread Greg Schafer
On Wed, Aug 30, 2006 at 12:03:51AM -0400, Paul Jarc wrote: > Greg Schafer <[EMAIL PROTECTED]> wrote: > > #!/bin/sh > > set -e > > > > func () { > > false && echo false > > true && echo true > > false && echo f

Re: functions and set -e

2006-08-29 Thread Greg Schafer
line 2 as "func && echo false" to > see the difference. Thanks for trying to clarify it for me. Let me put it another way: If I change Line 1 above to an if/then style statement instead of "&&" ie: if false; then echo false; fi it works e

Re: functions and set -e

2006-08-29 Thread Greg Schafer
On Wed, Aug 30, 2006 at 01:01:06AM -0400, Paul Jarc wrote: > Greg Schafer <[EMAIL PROTECTED]> wrote: > > Thanks for trying to clarify it for me. Let me put it another way: If I > > change Line 1 above to an if/then style statement instead of "&&" ie:

possible history bug?

2006-09-06 Thread Greg Whynott
ls 65 history 66 echo $SHELL 67 history | tail -5 torproxy:~ # history | tail -6 62 ls 63 cd 64 ls 65 history 66 echo $SHELL 67 history | tail -5 torproxy:~ # SLES 10 on i386. bash --version GNU bash, version 3.1.17(1)-release (i586-suse-linux) -- Gr

bash-3.2 parse error

2006-10-12 Thread Greg Schafer
h -n testcase testcase: line 1: unexpected EOF while looking for matching ``' testcase: line 2: syntax error: unexpected end of file It appears to be the `#' character in between the single quotes giving the grief. That line works with every bash version prior to 3.2. Thoughts? Thanks Greg

intl.tests failure

2006-11-28 Thread Greg Schafer
ll.c makes the testsuite pass as does running the testsuite like this: make tests LC_ALL= Maybe this test needs some robustification, thoughts? Regards Greg ___ Bug-bash mailing list Bug-bash@gnu.org http://lists.gnu.org/mailman/listinfo/bug-bash

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 vers

[PATCH] safelocale

2009-02-28 Thread Greg Wooledge
griffon:~/tmp$ shopt -s safelocale griffon:~/tmp$ echo $"How are you?" Como esta, $(id)? griffon:~/tmp$ shopt -u safelocale griffon:~/tmp$ echo $"How are you?" Como esta, uid=1000(greg) gid=1000(greg) grupos=24(cdrom),25(floppy),29(audio),40(src),1000(greg),1007(freenet)?

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=$

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 . -prin

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" "187431

Re: new redirection operator seems broken

2009-03-12 Thread Greg Wooledge
On Wed, Mar 11, 2009 at 09:50:18PM -0400, m...@ice.filescope.com wrote: > rm 2>&1 | grep --color op > rm |& grep --color op > > Notice that they are behaving differently. Confirmed in 4.0.0 and 4.0.10: imadev:~$ rm 2>&1 | tr '[:lower:]' '[:upper:]' USAGE: RM [-R

Re: Creating directories with sticky bit set

2009-03-12 Thread Greg Wooledge
On Thu, Mar 12, 2009 at 09:50:49AM +0200, Angel Tsankov wrote: > What can I do so that every directory I create has the sticky bit set? If you only ever create directories from interactive shells with the "mkdir" command, you could override it with a function: mkdir() { command mkdir "$@" &&

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 2>&1 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 wh

Re: Bash-4 breaks $() 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 c

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 examp

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? > >

"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: contents of whole arrays dissapears leaving while read loop

2009-03-26 Thread Greg Wooledge
On Thu, Mar 26, 2009 at 10:38:20AM +0100, Jan Schampera wrote: > Lennart Schultz wrote: > > cat file|while read line > > do > > done > How to do it instead? > http://bash-hackers.org/wiki/doku.php/syntax/expansion/proc_subst In this case, he doesn't need a process substitution -- he's just readin

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 chang

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 fr

Re: TIMEOUT

2009-04-06 Thread Greg Wooledge
On Sat, Apr 04, 2009 at 08:37:32AM -0300, Sergio Charpinel Jr. wrote: > So, first of all, I'm trying to find a way to combine TMOUT variable with > vlock. What's vlock? > I just found a way to do this in zhs. And if it is not possible, I > need to set TIMEOUT just for root, and it can't logout wh

Re: Bash 4 cursor in my prompt

2009-04-08 Thread Greg Wooledge
On Tue, Apr 07, 2009 at 11:04:58PM -0700, Special Sauce wrote: > > [an...@nobby-nobbs ~]$ echo $PS1 > [\[\e[28;1m\...@\h\[ \e[0m\]\w]$ ^^^ The space after \[ is not correct. You're sending a space to the terminal (or possibly more than one space -- since you didn't quote "$PS1

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

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 her

Re: backward-kill-word is not refreshing correctly

2009-04-14 Thread Greg Wooledge
On Mon, Apr 13, 2009 at 11:45:33PM -0400, Matt Zyzik wrote: > > > PS1='[\[\033[01;32m\]\u \[\033[01;31m\]- \[\033[01;34m\]\w\[\033[00m\]]$ ' > First, set your PS1 to the > above. It should result in a colored prompt. Second, type "asdf" so many > times that it goes passed the width of the terminal

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

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 int

Re: bash does not read startup scripts on some machines

2009-04-24 Thread Greg Wooledge
On Thu, Apr 23, 2009 at 02:14:24PM -0600, Justin wrote: > I am using a command line ssh tool called qtssh on windows to connect to > a redhat server. qtssh is a command line ssh tool [...] > 'When bash is started non-interactively, to run a shell > script, for example, it looks for the var

Re: Syntax for tab character

2009-04-24 Thread Greg Wooledge
On Fri, Apr 24, 2009 at 11:32:09AM -0600, Bill Gradwohl wrote: > What I want to do is remove all the space and tab characters. parameter=${parameter//[[:space:]]/} or parameter=${paramter//[ $'\t']/} >From an older bash(1) manual: Words of the form $'string' are treated specially. The

Re: indirection as an lvalue

2009-04-24 Thread Greg Wooledge
On Fri, Apr 24, 2009 at 11:49:43AM -0600, Bill Gradwohl wrote: > This is a trivial example, but gives you the idea. > for x in 'VAR_A' 'VAR_B' 'VAR_C'; do ># What I'd like to say is >!x="hello" > done In bash 4, you can use associative arrays, which gives you what you really want. Apart

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) con

<    4   5   6   7   8   9   10   11   12   13   >