[PATCH] confusing/obsolete handling of test -t operator (and doc warnings against using -o/-a)

2023-07-05 Thread Stephane Chazelas
Hello, test -t X Always returns false and doesn't report an error about that invalid number (beside the point here, but in ksh/zsh, that X is treated as an arithmetic expression and evaluates to 0 if $X is not set). While: test -t X -a Y returns a "too many arguments" error. test X -a -t -a Y

Re: [PATCH] confusing/obsolete handling of test -t operator (and doc warnings against using -o/-a)

2023-07-08 Thread Stephane Chazelas
2023-07-07 15:52:28 -0400, Chet Ramey: [...] > Historical versions of test made the argument to -t optional here. I can > continue to support that in default mode for backwards compatibility, but > it will be an error in posix mode. [...] I think you may have overlooked the bottom part of my email

Re: RFC: changing printf(1) behavior on %b

2023-08-31 Thread Stephane Chazelas
2023-08-31 10:35:59 -0500, Eric Blake via austin-group-l at The Open Group: > In today's Austin Group call, we discussed the fact that printf(1) has > mandated behavior for %b (escape sequence processing similar to XSI > echo) that will eventually conflict with C2x's desire to introduce %b > to pri

Re: RFC: changing printf(1) behavior on %b

2023-08-31 Thread Stephane Chazelas
2023-09-01 07:13:36 +0100, Stephane Chazelas via austin-group-l at The Open Group: > 2023-08-31 10:35:59 -0500, Eric Blake via austin-group-l at The Open Group: > > In today's Austin Group call, we discussed the fact that printf(1) has > > mandated behavior for %b (escape

Re: RFC: changing printf(1) behavior on %b

2023-09-01 Thread Stephane Chazelas
2023-09-01 09:44:08 +0300, Oğuz via austin-group-l at The Open Group: > On Fri, Sep 1, 2023 at 7:41 AM Phi Debian wrote: > > My vote is for posix_printf %B mapping to libc_printf %b > > In the shell we already have bc for base conversion. Does POSIX really > have to support C2x %b in the first pl

Re: bug#65659: RFC: changing printf(1) behavior on %b

2023-09-01 Thread Stephane Chazelas
2023-08-31 15:02:22 -0500, Eric Blake via austin-group-l at The Open Group: [...] > The current POSIX says that %b was added so that on a non-XSI > system, you could do: > > my_echo() { > printf %b\\n "$*" > } That is dependant on the current value of $IFS. You'd need: xsi_echo() ( IFS=' '

Re: bug#65659: RFC: changing printf(1) behavior on %b

2023-09-01 Thread Stephane Chazelas
2023-09-01 07:15:14 -0500, Eric Blake: [...] > > Note that in bash, you need both > > > > shopt -s xpg_echo > > set -o posix > > > > To get a XSI echo. Without the latter, options are still > > recognised. You can get a XSI echo without those options with: > > > > xsi_echo() { > > local IFS='

Re: bug#65659: RFC: changing printf(1) behavior on %b

2023-09-01 Thread Stephane Chazelas
2023-09-01 07:54:02 -0500, Eric Blake via austin-group-l at The Open Group: [...] > > Well in all case %b can not change semantic in the bash script, since it is > > there for so long, even if it depart from python, perl, libc, it is > > unfortunate but that's the way it is, nobody want a semantic

Re: bug#65659: RFC: changing printf(1) behavior on %b

2023-09-02 Thread Stephane Chazelas
2023-09-01 23:28:50 +0200, Steffen Nurpmeso via austin-group-l at The Open Group: [...] > |FWIW, a "printf %b" github shell code search returns ~ 29k > |entries > |(https://github.com/search?q=printf+%25b+language%3AShell&type=code&l=Sh\ > |ell) > | > |That likely returns only a small subset

Re: cd with multiple arguments?

2010-12-13 Thread Stephane CHAZELAS
2010-12-13, 12:04(+00), Marc Herbert: [...] >> True, bash does not come with a vast library of ready-to-use functions. > > Neither is there any such "reference" library available externally. Or > is there? Yes, they're called "commands" or "programs" or "software". People tend to forget that befo

Re: backslash required for [\/]

2010-12-26 Thread Stephane CHAZELAS
2010-12-25, 20:30(+08), jida...@jidanni.org: [...] > While we are here, here's another interesting phenomena, > $ touch aa > $ echo a[ab] > aa > $ echo a[ab/] > a[ab/] > $ echo a[ab\/] > a[ab/] > $ mkdir ab #doesn't help... That's the same as in every other shell and as specified by POSIX. So, any

Re: read builtin does not return success code (0) in spite of it successfully read line

2010-12-26 Thread Stephane CHAZELAS
2010-12-24, 13:20(+05), Коренберг Марк: [...] > mma...@mmarkk-work:/tmp$ echo aaa > /tmp/test1 > mma...@mmarkk-work:/tmp$ read x < /tmp/test1 && echo success > success > mma...@mmarkk-work:/tmp$ echo $x > aaa > mma...@mmarkk-work:/tmp$ > > BUGGY CASE: > mma...@mmarkk-work:/tmp$ echo -n bbb > /tmp/t

Re: read not terminated with EOF/^D when -n or -N is used

2010-12-27 Thread Stephane CHAZELAS
2010-12-26, 18:19(-05), Isaac Good: [...] > read <^D> -> the EOF terminates read and it exists with a false > exist status. > read -n4 <^D> -> the ^D is read by read and stored in REPLY. read > does not terminate. It's not bash that handles the ^D, it's the terminal. When in canonical mo

Re: $? in the right side of a pipe

2010-12-27 Thread Stephane CHAZELAS
2010-12-27, 13:14(+01), : > Hello > > More information on that topic : > > false ; false | echo $? stills prints 0. > false ; (false) | echo $? prints 1 > > So.. ? $? in the right side of a pipe is randomly the exit > status of the left side depending of the way you write it ? > Doesn’t soun

Re: read builtin does not return success code (0) in spite of it successfully read line

2010-12-27 Thread Stephane CHAZELAS
2010-12-27, 09:43(-07), Eric Blake: [...] > On 12/26/2010 01:29 PM, Stephane CHAZELAS wrote: >> Bash behavior is the same as every other shell, is as documented >> and as specified by POSIX. > > POSIX requires that the input to read be a text file. Since you aren't

Re: read builtin does not return success code (0) in spite of it successfully read line

2010-12-27 Thread Stephane CHAZELAS
2010-12-27, 11:53(-07), Eric Blake: [...] >> So I think you can expect a non-zero status here. > > All you can expect is that you have undefined results. Undefined > results include zero status. [...] Yes, sorry, you're right. Bad reasoning of mine. The >0 on EOF is oviously on end of text file,

Re: Bug in shell: buffer overflow.

2011-01-01 Thread Stephane CHAZELAS
2010-12-31, 11:33(-07), Bob Proulx: [...] > Your expressions above are overflowing the value of your system's > maximum integer size. You can read the system's maximum integer size > using getconf. > > $ getconf INT_MAX > 2147483647 [...] POSIX requires that arithmetic expansion be using at l

Re: Inconsitent treatment of * (globbing)

2011-01-31 Thread Stephane CHAZELAS
2011-01-31, 11:44(-05), Greg Wooledge: > On Sat, Jan 29, 2011 at 12:58:56PM +0100, Pascal Wittmann wrote: >> But if I use the expression ".*" in bash, I would expect from the >> behaviour of "*", that >> ".*" don't include the file "..". But the fact is, that it does in bash. > > This is done f

Re: Document what's allowed in function names

2011-05-24 Thread Stephane CHAZELAS
2011-04-11, 09:51(-04), Chet Ramey: >> Machine Type: i686-pc-linux-gnu >> >> Bash Version: 4.2 >> Patch Level: 8 >> Release Status: release >> >> Description: >> man bash is currently lacking information on what is allowed for >> function >> names. It implies name with name () compound

Re: Document what's allowed in function names

2011-05-25 Thread Stephane CHAZELAS
2011-05-24 17:23:20 -0400, Chet Ramey: [...] > > Why would you put any restriction on the allowed name of a function? [...] > Because Posix does, and because unset without -f has to enforce the variable > name restrictions. (Though the language has been relaxed in the latest > standard.) [...] PO

usenet to email gateway

2011-08-10 Thread Stephane Chazelas
Hiya, not sure who to report that to, but it looks like the usenet to mailing-list gateway at least for gnu.bash.bug is not working properly. That is, messages posted to the newsgroup are not sent to the corresponding mailing list. Compare for instance http://thread.gmane.org/gmane.comp.shells.ba

Re: usenet to email gateway

2011-08-11 Thread Stephane CHAZELAS
2011-08-10 23:05:26 +, Karl Berry: > not sure who to report that to > > I've asked the FSF sysadmins. I can see from the mailing list > configuration that the gateway is intended to be operational, but don't > know how to debug what it happening from there. [...] Thanks Karl. My last su

Re: Bash source repository

2011-08-11 Thread Stephane CHAZELAS
2011-05-30, 06:34(+00), Michael Witten: [...] > Ben, it is generally a good idea to maintain the `Cc' list unless > explicitly asked. Beware that the bash mailing list also has a usenet interface (gnu.bash.bug) which has no notion of recipients let alone Cc. -- Stephane

Re: bug: return doesn't accept negative numbers

2011-08-11 Thread Stephane CHAZELAS
2011-08-08, 13:55(-07), Linda Walsh: [...] > and both 'exit' and 'return' should return error "ERANGE" if "--posix" is > set, and -1 is given. Iinvalid option doesn't make as much sense, in > this situtation, if it was -k or -m, sure...but in this case, it's a fact > that --posix artificially limi

Re: feature request: option to start script not from the very beginning of file

2011-08-11 Thread Stephane CHAZELAS
2011-08-02, 17:05(+04), Dmitry Bolshakov: [...] > perl has "-x" switch which makes it skip leading file contents until the > #!/bin/perl > line > > imho it would be good to have the same feature in bash What about: #! /bin/bash - :||:<<\#__END__ whatever you like here #__END__ your script star

Re: equivalent of Linux readlink -f in pure bash?

2011-08-11 Thread Stephane CHAZELAS
2011-08-9, 11:44(+10), Jon Seymour: > Has anyone ever come across an equivalent to Linux's readlink -f that > is implemented purely in bash? > > (I need readlink's function on AIX where it doesn't seem to be available). [...] What about: readlink_f() ( link=$1 max_iterations=40 while [ "$max_

Re: [OT] Re: feature request: option to start script not from the very beginning of file

2011-08-11 Thread Stephane CHAZELAS
2011-08-02, 23:41(+02), mhenn: > Am 02.08.2011 15:55, schrieb Stephane CHAZELAS: [...] >> What about: >> >> #! /bin/bash - >> :||:<<\#__END__ >> >> whatever you like here >> >> #__END__ [...] > Why did you use :||:<< ..

Re: equivalent of Linux readlink -f in pure bash?

2011-08-11 Thread Stephane CHAZELAS
2011-08-9, 09:24(+00), Stephane CHAZELAS: > 2011-08-9, 11:44(+10), Jon Seymour: >> Has anyone ever come across an equivalent to Linux's readlink -f that >> is implemented purely in bash? >> >> (I need readlink's function on AIX where it doesn't see

Re: equivalent of Linux readlink -f in pure bash?

2011-08-11 Thread Stephane CHAZELAS
2011-08-09, 11:29(+02), Bernd Eggink: > On 09.08.2011 03:44, Jon Seymour wrote: >> Has anyone ever come across an equivalent to Linux's readlink -f that >> is implemented purely in bash? > > You can find my version here: > > http://sudrala.de/en_d/shell-getlink.html > > As it contains some co

Re: equivalent of Linux readlink -f in pure bash?

2011-08-11 Thread Stephane CHAZELAS
2011-08-10, 12:00(+02), Bernd Eggink: [...] > function f > { > local OPTIND=1 > > echo "\$1=$1" > } > > while getopts "abcdefg" opt > do > echo "opt=$opt" > f $opt > done > > > Calling the sript like this works fine: > script -a -b -c > > B

Re: equivalent of Linux readlink -f in pure bash?

2011-08-11 Thread Stephane CHAZELAS
2011-08-09, 09:50(-04), Steven W. Orr: [...] > *) To remove the trailing slashes, instead of > > while [[ $file == */ ]] > do > file=${file%/} > done > > file=${file##*/}# file name > > just say > file="${file%${file

Re: How to match regex in bash? (any character)

2011-09-29 Thread Stephane CHAZELAS
2011-09-29, 13:52(-08), Roger: [...] > Since you're saying the regex description is found within either regex(3) or > regex(7), couldn't there be a brief note within the Bash Manual Page be > something > to the effect: [...] No, it's not. I suppose bash could say: See your system regex(3) implem

gnu.bash.bug usenet interface not working again

2011-10-02 Thread Stephane CHAZELAS
It worked for a while after I reported the issue and then it stopped again. That's very frustrating. -- Stephane

Re: initialisation bash variables

2011-10-02 Thread Stephane CHAZELAS
2011-08-15, 17:15(+02), Francky Leyn: > Hello, > > if you have a variable, say VAR, > and you don't assign it a value, > and afterwards you test it, > what is the value of $VAR then? > > random, or an empty string? [...] Upon startup, the shell makes one shell variable per environment variable who

Re: initialisation bash variables

2011-10-02 Thread Stephane CHAZELAS
2011-08-16, 22:24(+02), Francky Leyn: [...] > VAR=FALSE > # some command line procesing, that can set VAR to "TRUE" > if [ $VAR = TRUE ]; then > ... > fi > > Must I effectively write that VAR=FALSE? > Or will the script work fine without? Yes, you must write it, because bash may inherit a VAR vari

Re: initialisation bash variables

2011-10-02 Thread Stephane CHAZELAS
2011-08-17, 08:32(+02), Francky Leyn: > On 8/16/2011 10:53 PM, Stephane CHAZELAS wrote: >> 2011-08-16, 22:24(+02), Francky Leyn: >> [...] >>> VAR=FALSE >>> # some command line procesing, that can set VAR to "TRUE" >>> if [ $VAR = TRUE ]; then

Re: initialisation bash variables

2011-10-02 Thread Stephane CHAZELAS
2011-08-18, 04:10(+02), Patrick: > On 17.08.2011 20:53, Stephane CHAZELAS wrote: >> 2011-08-17, 08:32(+02), Francky Leyn: >>> On 8/16/2011 10:53 PM, Stephane CHAZELAS wrote: >>> 2) If VAR coincides with an environment variable, and in the >>> script I chan

Re: Syntax Question...

2011-10-02 Thread Stephane CHAZELAS
2011-08-14, 02:43(+00), Michael Witten: [...] >> Please read BashFAQ/006: http://mywiki.wooledge.org/BashFAQ/006 > > "no force in the universe can put NUL bytes into shell strings usefully" > > Ain't that the goddamn Truth! No, zsh supports NUL bytes in its strings happily. It's even in the defaul

Re: initialisation bash variables

2011-10-02 Thread Stephane CHAZELAS
2011-08-18, 12:44(+02), Patrick: [...] >> $ VAR=foo sh -c 'VAR=bar; env' | grep VAR >> VAR=foo >> $ VAR=foo sh -c 'VAR=bar; export VAR; env' | grep VAR >> VAR=bar > Interresting! I do not have the bourne shell installed. Bash tries to > mimic it when called as "sh", but it does not produce the "co

Re: Syntax Question...

2011-10-02 Thread Stephane CHAZELAS
2011-08-17, 08:24(-04), Greg Wooledge: > On Tue, Aug 16, 2011 at 03:41:19PM -0700, Linda Walsh wrote: >> Ken Irving wrote: >> >Maybe this? >> >today_snaps=( ${snap_prefix} ) > >> but as you mention, that will put them into an arraysorry "imprecise >> terminology" list for me is some n

[OT] Re: accents

2011-10-02 Thread Stephane CHAZELAS
2011-08-25, 12:19(-07), Linda Walsh: [...] > ` Greg Wooledge wrote: >> On Wed, Aug 24, 2011 at 06:51:32PM -0700, Linda Walsh wrote: >> >>> BTW, Thomas -- what is the Character that comes after 'De' in your >>> name? I read it as hex '0xc282c2' which doesn't seem to be valid unicode. >>> >

Re: Using TMOUT as default for read bultin is unwise

2011-10-02 Thread Stephane CHAZELAS
2011-09-14, 09:46(+01), Wheatley, Martin R: [...] > Description: > The contents of the environment variable TMOUT are used are the > default timeout for the read builtin command when reading from > a TTY or pipe AND as a shell command input idle time. > > This can lead to ra

Re: Bug fix for $((x**y)) algorithm on 64+ bits machines.

2011-10-02 Thread Stephane CHAZELAS
2011-09-16, 17:17(-07), William Park: > 145557834293068928043467566190278008218249525830565939618481 > is awfully big number! :-) 3**2**62 is 3**(2**62), 3**4611686018427387904, not a number you can represent with 64bits, nor any reasonable number of bits, not (3**2)**62. Certainly not a number

Re: Bug fix for $((x**y)) algorithm on 64+ bits machines.

2011-10-02 Thread Stephane CHAZELAS
2011-09-17, 13:06(+00), Stephane CHAZELAS: > 2011-09-16, 17:17(-07), William Park: >> 145557834293068928043467566190278008218249525830565939618481 >> is awfully big number! :-) > > 3**2**62 is 3**(2**62), 3**4611686018427387904, not a number you > can represent with 64

Re: How to match regex in bash? (any character)

2011-10-02 Thread Stephane CHAZELAS
2011-10-1, 14:39(-08), rogerx@gmail.com: [...] > I took some time to examine the three regex references: > > 1) > http://pubs.opengroup.org/onlinepubs/9699919799/basedefs/V1_chap09.html#tag_09_04 > Written more like a technical specification of regex. Great if your're > going to be mo

Re: Bug fix for $((x**y)) algorithm on 64+ bits machines.

2011-10-02 Thread Stephane CHAZELAS
2011-09-19, 09:27(-04), Chet Ramey: > On 9/16/11 4:39 PM, Nicolas ARGYROU wrote: > >> Bash Version: 4.0 >> Patch Level: 33 >> Release Status: release >> >> Description: >> The algorithm used to calculate x to the power of y: x**y >> takes O(y) time which is way too long on systems using 64

Re: List of background processes in a command group, in a pipeline, executed sequentially under certain conditions.

2011-10-02 Thread Stephane CHAZELAS
2011-10-01, 06:54(-05), Dan Douglas: [...] > f() { > local -i x y > while read -rN1 "x[y++]"; do > printf '%d ' "${1}" >&2# keep track of which job this is. > done > printf "${#x[@]} " # Print the total number of reads by each > job. if you add a echo >&2 "

Re: Bug fix for $((x**y)) algorithm on 64+ bits machines.

2011-10-02 Thread Stephane CHAZELAS
2011-09-17, 13:39(+00), Stephane CHAZELAS: > 2011-09-17, 13:06(+00), Stephane CHAZELAS: >> 2011-09-16, 17:17(-07), William Park: >>> 145557834293068928043467566190278008218249525830565939618481 >>> is awfully big number! :-) >> >> 3**2**62 is 3**(2**62), 3

Re: How to match regex in bash? (any character)

2011-10-03 Thread Stephane CHAZELAS
2011-10-02, 21:51(-04), Chet Ramey: > On 10/2/11 3:43 PM, Stephane CHAZELAS wrote: > >> [*] actually, bash does some (undocumented) preprocessing on the >> regexps, so even the regex(3) reference is misleading here. > > Not really. The words are documented to undergo

Re: How to match regex in bash? (any character)

2011-10-03 Thread Stephane CHAZELAS
2011-10-03, 13:48(+02), Andreas Schwab: > Stephane CHAZELAS writes: > >> The problem and confusion here comes from the fact that "\" is >> overloaded and used by two different pieces of software (bash >> and the system regex). > > That's nothing

Re: Syntax Question...

2011-10-03 Thread Stephane CHAZELAS
2011-10-3, 08:36(-04), Greg Wooledge: > On Thu, Aug 18, 2011 at 11:10:17AM +0100, Stephane CHAZELAS wrote: >> >> Please read BashFAQ/006: http://mywiki.wooledge.org/BashFAQ/006 >> > "no force in the universe can put NUL bytes into shell strings usefully" >

[OT] Re: Syntax Question...

2011-10-03 Thread Stephane CHAZELAS
2011-10-3, 09:12(-04), Greg Wooledge: > On Mon, Oct 03, 2011 at 12:56:43PM +0000, Stephane CHAZELAS wrote: >> If zsh is not compatible with any other shell, then bash isn't >> either. What do you mean? > > http://zsh.sourceforge.net/FAQ/zshfaq02.html#l10 > > "

Re: Error in manual for >&word redirection

2011-10-12 Thread Stephane CHAZELAS
2011-10-12, 14:39(-06), Eric Blake: > On 10/12/2011 02:07 PM, Greg Wooledge wrote: >> Even using a space is not sufficient to force a valid file descriptor number >> to be treated as a filename: >> >> imadev:~$ foo>& 1 >> stdout >> stderr >> imadev:~$ ls -l 1 >> 1 not found > > If you want 'word'

Re: How to automatically load alias from .bashrc in a bash script?

2011-10-27 Thread Stephane CHAZELAS
2011-10-27, 11:17(-05), Peng Yu: > I want to use some alias in a bash script. But I have to include the > following line in the script in order to use the alias defined in > ~/.bashrc. Is there a way to automatically load the alias from .bashrc > so that I don't have to explicitly include these two

Re: {varname} for redirection does not work with arrays

2011-11-05 Thread Stephane CHAZELAS
2011-11-2, 12:01(-06), unkn...@vmw-les.eng.vmware.com: [...] > Description: > If {varname} is an assoc. array in a redirection the exec will fail > The [] should not be confused with pathname expansion just like ${}. > > Repeat-By: > $ declare -A array > $ exec {array[key]}

Re: What is the best to pass an array with specially characters as command line arguments?

2011-11-07 Thread Stephane CHAZELAS
2011-11-6, 21:02(-06), Peng Yu: [...] > #!/usr/bin/env bash > > verbatim_string=" a b c ( a'b | " > > args="`echo \"$verbatim_string\" | sed -f quoteverb.sed`" > > cmd="echo $args" > eval "$cmd" > > ~$ ./main.sh > a b c ( a'b | Either: #! /bin/sh verbatim_string=" a b c ( a'b | " cmd='(set -f;

Re: feature request: printf %(%s)T

2011-11-23 Thread Stephane CHAZELAS
2011-11-23, 12:00(-05), Chet Ramey: > On 11/22/11 4:53 PM, Greg Wooledge wrote: >> This is a feature request, rather than a bug. Bash 4.2's printf command >> has a lovely %(datefmt)T feature that allows it to print out formatted >> timestamps using the underlying operating system's strftime(3) rou

Re: bash silently ignores additional arguments for cd

2011-12-08 Thread Stephane CHAZELAS
2011-12-07, 12:02(-07), Eric Blake: [...] > Or even nicer, behave like zsh, and treat > cd xxx yyy > like this (written assuming extglob syntax) > cd xxx+($' \t')yyy [...] Not sure what you're refering to, but cd xxx yyy in zsh means cd ${PWD/xxx/yyy} -- Stephane

Re: bash silently ignores additional arguments for cd

2011-12-08 Thread Stephane CHAZELAS
2011-12-8, 10:13(+00), Stephane CHAZELAS: > 2011-12-07, 12:02(-07), Eric Blake: > [...] >> Or even nicer, behave like zsh, and treat >> cd xxx yyy >> like this (written assuming extglob syntax) >> cd xxx+($' \t')yyy > [...] > > Not sure what

Re: extglob pattern: @(/root) vs. @(root)

2011-12-09 Thread Stephane CHAZELAS
2011-12-9, 16:16(+08), Clark J. Wang: > See following: > > # shopt extglob > extglob on > # echo $BASH_VERSION > 4.2.20(1)-release > # ls -d /root > /root > # pwd > / > # echo @(root) > root > # echo @(/root) > @(/root) <-- ??? > # echo @(/root*) > @(/root*) <-- ??? > # > > I'm confused w

help-bash mailing list (Was: lseek with bash)

2011-12-09 Thread Stephane CHAZELAS
2011-12-9, 10:27(-05), Greg Wooledge: [...] > This probably belongs on help-bash rather than bug-bash, although it's a > grey area. I'm Cc-ing both. [...] First time I hear about a "help-bash" mailing list. Is that new? I saw no annoucement in bash bug (I could have missed it though), nor does it

Re: return values of bash scripts

2011-12-21 Thread Stephane CHAZELAS
2011-12-20, 14:18(-08), kc123: [...] > Could someone please help me figure out why: > GNU bash, version 3.2.25(1)-release-(x86_64-redhat-linux-gnu) [...] Since you're using RedHat Linux, try ps -o comm= -C crond -- Stephane

Re: let's set the positional parameters with a simple 'read'

2012-01-03 Thread Stephane CHAZELAS
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

Re: I think I may have found a possible dos attack vector within bash.

2012-03-20 Thread Stephane Chazelas
2012-03-20 16:47:51 +, Eamonn Smyth: > Without sounding alarmist, I can break my machine using bash. I also have a > fix. I shall be officially releasing the c code this weekend at the > hackathon london. [...] A DOS vector often found is bash *scripts* is when a script takes user input in a v

Re: bash does filename expansion when assigning to array member in compound form

2012-08-18 Thread Stephane Chazelas
2012-08-18 10:26:22 -0500, Dan Douglas: > This is a feature that all shells with this style of compound assignment have > in common. If no explicit subscripts are given, the text between the > parentheses is processed exactly as though it were arguments to a command > including brace expansion,

Re: Bash 4.1 doesn't behave as I think it should: arrays and the environment

2012-08-19 Thread Stephane Chazelas
2012-08-17 17:18:12 -0400, Greg Wooledge: > On Fri, Aug 17, 2012 at 03:19:56PM +0800, John Summerfield wrote: > > In two cases I wish to pass an array in the environment, like so: > > 14:28 john@Boomer$ STUFF[1]=one STUFFX=stuffx env | grep ^ST > > STUFFX=stuffx > > STUFF[1]=one > > You are creati

Re: bash does filename expansion when assigning to array member in compound form

2012-08-20 Thread Stephane Chazelas
2012-08-20 19:44:51 +0200, Roman Rakus: [...] > And how would you achieve to fill array with all file names > containing `[1]=' for example. [...] Another interesting question is how to fill the array with all the file names that start with a digit followed by "=". $ touch {3..5}=foo $ ls 3=foo

expansion of \uXXXX in non utf8 locales

2012-12-20 Thread Stephane Chazelas
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' -DPACKA

moving fd affect outer scope

2013-02-18 Thread Stephane Chazelas
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' -DPACKA

0xFF and read -N

2013-08-31 Thread Stephane Chazelas
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' -DPACKA

Re: Following symlinks in globstar

2014-01-25 Thread Stephane Chazelas
2014-01-21 10:19:10 -0500, Chet Ramey: [...] > > I am not so worried about the method used to "fix" globstar -- whether > > we keep backwards compatibility or not -- I am more concerned that we > > have at least *some* way of disabling what many people view as > > undesirable behaviour. > > It may

Re: let's establish BASH_MINIMUM_TIME_BETWEEN_INTERACTIVE_COMMAND

2014-01-30 Thread Stephane Chazelas
2014-01-30 12:45:58 +0200, Pierre Gaston: > On Thu, Jan 30, 2014 at 12:37 PM, Dan Jacobson wrote: > > > Thanks fellows but now bash has become very slow to the touch that way. > > > > Maybe try something like: PROMPT_COMMAND='read -t0 && sleep 10' Or PROMPT_COMMAND="perl -MPOSIX -e 'tcflush 0,

Re: Following symlinks in globstar

2014-03-18 Thread Stephane Chazelas
2014-02-04 09:23:21 -0500, Chet Ramey: > On 1/25/14 6:11 PM, Stephane Chazelas wrote: > > 2014-01-21 10:19:10 -0500, Chet Ramey: > > [...] > >>> I am not so worried about the method used to "fix" globstar -- whether > >>> we keep backwards co

regression: extglobs expand hidden files in 4.3

2014-03-18 Thread Stephane Chazelas
With bash-4.3 as found on Debian's 4.3-2 package: $ bash -cO extglob 'echo *(.)' . .. $ bash -cO extglob 'echo *(foo)*' . .. a $ bash -cO extglob 'echo @(|foo)*' . .. a It looks like the regression was introduced by 4.3, as 4.2 doesn't exhibit the same problem. This one's OK: $ bash -cO extglo

Re: ctrl-c does not send INT to all processes under foreground job

2014-03-19 Thread Stephane Chazelas
2014-03-19 04:07:06 +, Ryan Ruan: [...] > It is said that "ctrl-C sends INT to ALL processes under foreground job", but > i found a weird phenomenon. > I have not read source code yet, but it does not seem to ascribe to what > specification says. > > Test code is like: > > 1 tr

Re: ctrl-c does not send INT to all processes under foreground job

2014-03-19 Thread Stephane Chazelas
2014-03-19 09:51:06 -0400, Chet Ramey: [...] > This is another instance of the question "what does bash do with a SIGINT > it receives while waiting for a foreground process?" The answer is that it > allows the child to decide what to do and responds accordingly: if the > child exits due to being

minor: "read line" may read several lines if stdin is a tty

2014-08-25 Thread Stephane Chazelas
If you run (here testing on Linux): bash -c 'read a; echo "<$a>"; tr b c' And enter aaabbb You see "", but not "ccc". That's because "read" reads up to 128 bytes of data in one read(2) invocation instead of reading one byte at a time like on other types on non-seekable files. Probably not a b

[doc] confusion over $0 and positional parameters

2014-08-27 Thread Stephane Chazelas
In info -f bash -n 'Invoking Bash' we find: > `-c' > Read and execute commands from the first non-option ARGUMENT after > processing the options, then exit. Any remaining arguments are > assigned to the positional parameters, starting with `$0'. $0 is generally *not* considere

Re: minor: "read line" may read several lines if stdin is a tty

2014-08-27 Thread Stephane Chazelas
2014-08-27 08:10:01 -0400, Chet Ramey: > On 8/25/14, 4:24 PM, Stephane Chazelas wrote: > > If you run (here testing on Linux): > > > > bash -c 'read a; echo "<$a>"; tr b c' > > > > And enter aaabbb > > > > You see "

Re: minor: "read line" may read several lines if stdin is a tty

2014-08-29 Thread Stephane Chazelas
2014-08-27 15:35:06 -0400, Chet Ramey: > On 8/27/14, 3:20 PM, Stephane Chazelas wrote: > > > However, one could imagine using bash's read to get data off a > > tty device not in canonical mode (a serial device used as just a > > serial device), or any other non-

Re: make 'tr' (or something like it) a bash builtin ?

2006-02-13 Thread Stephane Chazelas
On Sun, Feb 05, 2006 at 07:02:10PM -0500, Chris F.A. Johnson wrote: > On Sun, 5 Feb 2006, Felipe Kellermann wrote: > > >On Thu, 2 Feb 2006 11:13pm -0500, Mike Frysinger wrote: > > > >>upper case or lower case ... if 'tr' was a bash builtin, then that'd work > >>with some `echo | tr` magic, but it

Re: bash shell parser bug

2006-03-20 Thread Stephane Chazelas
On Thu, Mar 16, 2006 at 08:28:28PM -0800, laura fairhead wrote: > > > Hello, Hi Laura, > I just found a bug that affects a number of shells (pressumably the > code there is from the same roots) in the parser. > > The following code; > > l='eval "$l"' > eval "$l" > > Which sets off an infinit

Re: check_dev_tty - What does it do?

2006-06-23 Thread Stephane Chazelas
On Fri, Jun 23, 2006 at 02:54:04PM +1200, John Carter wrote: > > Here is the bash-3.1 code from general.c for check_dev_tty. > > It is invoked shortly after main... > > void > check_dev_tty () > { > int tty_fd; > char *tty; > > tty_fd = open ("/dev/tty", O_RDWR|O_NONBLOCK); > > if (tty

Re: PATH and $0

2006-07-12 Thread Stephane Chazelas
On Tue, Jul 11, 2006 at 08:19:34PM -0400, Dave Rutherford wrote: > On 7/11/06, Cai Qian <[EMAIL PROTECTED]> wrote: > >I want its full pathname using 'dirname', but it will give me > >unexpected result on some Linux or Bash versions. > > Well, 'dirname' certainly won't do what you want, but I'm sor

Re: PATH and $0

2006-08-02 Thread Stephane Chazelas
On Thu, Jul 13, 2006 at 11:53:00PM -0600, Bob Proulx wrote: > Stephane Chazelas wrote: > > $0 will always contain the file path, unless the script was > > started as: > > > > bash script.sh > > > > And there's no script.sh in the current directory (i

Re: PATH and $0

2006-08-14 Thread Stephane Chazelas
On Sat, Aug 12, 2006 at 01:51:12AM -0600, Bob Proulx wrote: > Stephane Chazelas wrote: > > [ -e "$cmd" ] || cmd=$(command -v -- "$cmd") || exit > > Bob Proulx wrote: > > > Of course using command as you have done will work for bash. > > > &g

Re: ...Limitation?

2006-09-26 Thread Stephane Chazelas
On Tue, Sep 26, 2006 at 11:45:42AM -0400, Paul Jarc wrote: > mwoehlke <[EMAIL PROTECTED]> wrote: > > I am trying to figure out how to run a command and pipe the output > > through tee, and then check the status of the original command. > > This uses a bash-specific feature: > cmd > >(tee file); s

Re: Fatal bug with redirection

2006-10-04 Thread Stephane Chazelas
On Wed, Oct 04, 2006 at 03:38:12PM -0400, Yang wrote: > On my FC5 box, when I try certain things in bash 3.1.7(1)-release > involving redirection, such as the following, bash crashes > (immediately exits): > > { echo a >&3 ; } 3> >( echo b ) > > I've only tried this from an interactive shell. Unf

Re: Curly braces expansion not always works as expected.

2006-10-06 Thread Stephane Chazelas
On Thu, Oct 05, 2006 at 12:23:41AM +0200, Reuti wrote: [...] > Curly braces expansion only works with at least one comma > (,). This also works, if the appears at least once > inside some apostrophes and has no function. > > Repeat-By: > [EMAIL PROTECTED]:~> bash --versio

Re: case statement breaks $( ) substitution

2006-10-06 Thread Stephane Chazelas
On Fri, Oct 06, 2006 at 11:55:27AM +0200, [EMAIL PROTECTED] wrote: [...] > Repeat-By: > > $ echo $( > > case a in > > 1) :;; > bash: syntax error near unexpected token `;;' > > The closing `)' is misinterpreted as being the end of the `$(' > s

Re: How to detect bash?

2006-10-10 Thread Stephane Chazelas
On Tue, Oct 10, 2006 at 05:12:07PM -0500, mwoehlke wrote: > Dave Rutherford wrote: > >On 10/10/06, mwoehlke <[EMAIL PROTECTED]> wrote: > >>Anyone have any clever, VERY reliable tricks for detecting if the > >>current shell is bash? > > > >Well, I don't know if it's clever, but how about: > > Oh, m

Re: How to detect bash?

2006-10-11 Thread Stephane Chazelas
On Tue, Oct 10, 2006 at 06:14:22PM -0500, mwoehlke wrote: [...] > >$ zsh -c 'echo "`/dev/null 2>&1`"' bash > >bash: /dev/null: Permission denied > > > >$ zsh > >$ ARGV0=bash ash -c 'echo "`/dev/null 2>&1`"; echo $BASH' > >bash: /dev/null: Permission denied > > Eh? I get: > > $ zsh -c 'echo "`/dev

Re: ${//}: say how to non-destructively prefix/suffix

2006-11-05 Thread Stephane Chazelas
On Mon, Nov 06, 2006 at 02:54:25AM +0800, Dan Jacobson wrote: > Regarding the >${parameter/pattern/string} >${parameter//pattern/string} > discussion on the man page: > You don't mention what if pattern is null. > Seems that will never match. > Anyway, no way to > $ set aa bb cc > $

Re: strange expansion of <(cat p.main.{optional,extra})

2007-04-18 Thread Stephane Chazelas
On Tue, Apr 17, 2007 at 08:16:53PM -0400, Chet Ramey wrote: [...] > > The expansion of echo <(cat /etc/{passwd,motd}) is rather surprising: > > $ echo <(cat p.main.{optional,extra}) > > ++ cat p.main.optional > > cat: p.main.optional: No such file or directory > > ++ cat p.main.extra > > cat: p.ma

Re: Bash is broken

2007-05-13 Thread Stephane Chazelas
On Sun, May 13, 2007 at 12:31:48AM -0700, Overdorf, Sam wrote: > The following does not work on my computers: [...] > If [ "1" > "2" ] [...] > Bash thinks this is I/O redirection and creates a file by the name of > "2" in my directory. > > This should be a string compare. [...] Hi. No, this shoul

Re: Bash is broken

2007-05-13 Thread Stephane Chazelas
On Sun, May 13, 2007 at 08:19:13AM -0600, Eric Blake wrote: [...] > if [[ 1 > 2 ]] > > > This should be a string compare. > > Actually, when quoted properly, it should be a numeric comparison, not a > string comparison. [...] It *is* a string comparison: $ bash -c '[[ 02 > 1 ]]' || echo "02 is

Re: wrong logical evaluation of expressions involving true or false commands

2007-06-25 Thread Stephane Chazelas
On Mon, Jun 25, 2007 at 02:07:56PM -0600, Bob Proulx wrote: [...] > following. These are the same. > > [ foo -a bar ] > [ -n foo -a -n bar ] > > This is defined by standard by the number of arguments. > > http://www.opengroup.org/onlinepubs/009695399/utilities/test.html [...] And it shou

Re: logical XOR

2007-06-29 Thread Stephane Chazelas
On Fri, Jun 29, 2007 at 10:21:01AM +0200, Robert Millan [ackstorm] wrote: [...] > > > There's bitwise AND and bitwise OR, and logical AND and logical OR, but > > > for XOR there's only the bitwise version. Would be nice if the logical > > > XOR would also be present (^^). > > > > (!a) != (!

Re: logical XOR

2007-06-29 Thread Stephane Chazelas
On Fri, Jun 29, 2007 at 12:08:22PM +0200, Robert Millan [ackstorm] wrote: > On Fri, Jun 29, 2007 at 10:16:18AM +0100, Stephane Chazelas wrote: > > > > Do you mean that for instance, you'd like a third command to be > > executed if either but not both of two commands

Re: printf '\x' exit status is 0

2007-07-11 Thread Stephane Chazelas
On Tue, Jul 10, 2007 at 09:35:56PM -0400, Chet Ramey wrote: > Poor Yorick wrote: > > (on my debian system, bashbug reports for bash 2.05) > > > > printf status is 0 but /usr/bin/printf is 1. Is this the expected behavior? > > > > [EMAIL PROTECTED]:~$ bash3 > > [EMAIL PROTECTED]:~$ bash3 --versio

  1   2   3   4   5   >