$PS5, for sh -v!

2018-04-03 Thread 積丹尼 Dan Jacobson
$PS4 is for sh -x. Well, $PS5 or $PSv should be for sh -v! Imagine, with just a simple PS5='$ ', one could produce perfect dialogues, $ set -eu /tmp/x $ mkdir $@ $ cd $@ $ seq 3|xargs touch $ ls -U $@ 3 2 1 $ mv -v $@ /var$@ created directory '/var/tmp/x' copied '/tmp/x/1' -> '/var/tmp/x/1' cop

Re: A question about bash change for efficiency speedups in multibyte locales

2018-04-03 Thread yangyajing
I don't think it should check for '[:',  but it should check if the pattern is defined in the charclass even if the pattern does not have a multibyte character. when the pattern is one of the character classes defined in the POSIX standard such as xdigit, these two lines of code can indeed speed

Re: odd error from bash exec binary on cmd line

2018-04-03 Thread L A Walsh
Chet Ramey wrote: On 3/24/18 3:31 PM, L A Walsh wrote: bash sleep 1 I get: /usr/bin/sleep: /usr/bin/sleep: cannot execute binary file ??? Isn't it bash that cannot execute the binary file because it expected a script? Think about what happens when you run a command like that. Bas

Re: What should be the expected behavior for $_ ?

2018-04-03 Thread L A Walsh
Chet Ramey wrote: On 4/3/18 10:03 AM, Siteshwar Vashisht wrote: $ mkdir testdir $ cp rpmall.txt rpmshort.txt $_ # Use tab completion to complete filenames cp: target '_filedir' is not a directory Last command fails because tab completing 'cp' command modifies value of '$_'. Shall value of

Re: Error message garbage when parameter expansion used inside (()) and variable unset

2018-04-03 Thread PRussell
Hi, The error seems to be localized to the expansion of PS4 when "set -x" is active. Please see sample script below. I am aware of the unusual parameter expansion for FUNCNAME. There might be a local historical reason. :-) It does not happen outside of the PS4 expansion. It also behaves diffe

Re: Error message garbage when parameter expansion used inside (()) and variable unset

2018-04-03 Thread Chet Ramey
On 4/3/18 1:15 PM, PRussell wrote: > Chet, is the output on opensuse running bash 4.4.19, correct? > > The specific output: > > ./t.sh: line 9: ���#V: var1 ==  : syntax error: operand expected (error > token is "==  ") > > archlinux has the same version of bash and I got the same results as on

Re: Error message garbage when parameter expansion used inside (()) and variable unset

2018-04-03 Thread Greg Wooledge
On Tue, Apr 03, 2018 at 12:15:14PM -0500, PRussell wrote: > ./t.sh: line 9: ���#V: var1 == : syntax error: operand expected (error > token is "== ") > > archlinux has the same version of bash and I got the same results as on > opensuse. I cannot reproduce this on Debian 9 amd64. Not with Debi

Re: Error message garbage when parameter expansion used inside (()) and variable unset

2018-04-03 Thread PRussell
Chet, is the output on opensuse running bash 4.4.19, correct? The specific output: ./t.sh: line 9: ���#V: var1 == : syntax error: operand expected (error token is "== ") archlinux has the same version of bash and I got the same results as on opensuse. Below are the details of running ./

Re: A question about bash change for efficiency speedups in multibyte locales

2018-04-03 Thread Chet Ramey
On 4/2/18 10:59 PM, yangyajing wrote: > Thanks for your reply. > > The two lines of code are as follows which in the xstrmatch() function in > bash-4.3/lib/glob/smatch.c: > >   if (mbsmbchar (string) == 0 && mbsmbchar (pattern) == 0) >     return (internal_strmatch ((unsigned char *)pattern, (un

Re: What should be the expected behavior for $_ ?

2018-04-03 Thread Chet Ramey
On 4/3/18 10:03 AM, Siteshwar Vashisht wrote: > According to bash reference manual[1]: > > ($_, an underscore.) At shell startup, set to the absolute pathname used to > invoke the shell or shell script being executed as passed in the environment > or argument list. Subsequently, expands to the l

Re: What should be the expected behavior for $_ ?

2018-04-03 Thread Greg Wooledge
On Tue, Apr 03, 2018 at 10:03:30AM -0400, Siteshwar Vashisht wrote: > $ mkdir testdir > $ cp rpmall.txt rpmshort.txt $_ # Use tab completion to complete filenames > cp: target '_filedir' is not a directory > > Last command fails because tab completing 'cp' command modifies value of > '$_'. Shall

What should be the expected behavior for $_ ?

2018-04-03 Thread Siteshwar Vashisht
According to bash reference manual[1]: ($_, an underscore.) At shell startup, set to the absolute pathname used to invoke the shell or shell script being executed as passed in the environment or argument list. Subsequently, expands to the last argument to the previous command, after expansion.

Re: Error message garbage when parameter expansion used inside (()) and variable unset

2018-04-03 Thread Chet Ramey
On 4/2/18 5:16 PM, PRussell wrote: > Section 6.5 Shell Arithmetic says, > > "Within an expression, shell variables may also be referenced by name without > using the parameter expansion syntax. A shell variable that is null or unset > evaluates to 0 when referenced by name without using the parame

Re: Error message garbage when parameter expansion used inside (()) and variable unset

2018-04-03 Thread Daniel Mills
On Mon, Apr 2, 2018 at 5:16 PM, PRussell wrote: > > echo 4B > ( set -x;var=5;var1=var; (( var1 == $var2 )) && echo yes || echo no ) > > > It appears that 3A and 4A evaluate to 0 because of the arithmetic context. > 3A echo's yes; 4A echo's no. > > The problem is what is happening with 3B and 4B

Re: Error message garbage when parameter expansion used inside (()) and variable unset

2018-04-03 Thread Greg Wooledge
On Mon, Apr 02, 2018 at 04:16:54PM -0500, PRussell wrote: > The above tells us what happens to an unset variable if not using parameter > expansion. > > But if a shell variable uses parameter expansion and is null or unset, what > does it evaluate to inside (()) syntax? The parameter expansion