Re: GNU Bash v.4.4.23-5 built-in function 'set' produces variable outputs

2018-10-23 Thread Greg Wooledge
On Tue, Oct 23, 2018 at 02:06:37PM +0700, Robert Elz wrote: > Interactively you're much more > likely to want !$ than $_ (I'd suggest infinitely more lijkely...) You mean negative infinity. wooledg:~$ grep histexpand .bashrc set +o histexpand

Re: Environment variable "PS4" can not be passed to bash script from version 4.2.46(2)

2018-10-23 Thread Greg Wooledge
On Tue, Oct 23, 2018 at 03:20:12PM +, Chen, Farrah wrote: > But in Bash script, it cannot work, it keeps its original value: > [root@fchen ~]# cat test.sh > #!/usr/bin/bash > echo $PS4 > echo $FAN This is because you're doing it as root. Bash strips PS4 from the environment when started as ro

Re: [minor] umask 400 causes here-{doc,string} failure

2018-10-29 Thread Greg Wooledge
On Sun, Oct 28, 2018 at 09:30:00PM -0400, Chet Ramey wrote: > That doesn't work for the same reason as discussed in > http://lists.gnu.org/archive/html/bug-bash/2018-03/msg00074.html. > It's unlikely that someone will set his umask to 400 and expect no ill > effects, but I suppose it's better not t

Re: Indices of array variables are sometimes considered unset (or just display an error).

2018-11-06 Thread Greg Wooledge
On Mon, Nov 05, 2018 at 08:04:49PM -0500, Great Big Dot wrote: > Hold up... when I view this email on the public archives, all of my > "${array[@]}"'s (that is, "${array[]}"'a) got turned to > "address@hidden"'s. Sadly, there's nothing we can do about that. The maintainers of the list archive wou

Re: The builtin array variable 'FUNCNAME' is considered unset by many expansions, even when set.

2018-11-08 Thread Greg Wooledge
On Thu, Nov 08, 2018 at 01:15:56AM -0500, Great Big Dot wrote: > Description: > The builtin array variable FUNCNAME (which provides a way to trace the > stack of functions called so far) appears to be unset according to certain > bash expansions, even when it isn't. If the following code is saved t

Re: [mapfile]: problem reentrance with normal file

2018-11-12 Thread Greg Wooledge
On Sun, Nov 11, 2018 at 09:32:31PM +0100, Didou Serge wrote: > When use mapfile from normal file that call function that use mapfile, the > first mapfile lost data. > > Repeat-By: > I create 3 functions: > ww(){ echo "$@" | mapfile -C yy -c 1 -t TT ; } In this function, mapfile is being executed

Re: Strange behaviour from jobs -p in a subshell

2018-11-13 Thread Greg Wooledge
On Tue, Nov 13, 2018 at 09:59:51AM -0500, Chet Ramey wrote: > On 11/13/18 4:28 AM, Christopher Jefferson wrote: > > Consider the following script. While the 3 sleeps are running, both jobs > > -p and $(jobs -p) will print 3 PIDs. Once the 3 children are finished, > > jobs -p will continue to prin

Re: built-in '[' and '/usr/bin/[' yield different results

2018-11-13 Thread Greg Wooledge
On Tue, Nov 13, 2018 at 05:29:42PM +0100, Service wrote: > Repeat-By: >     Under Windows 10, WSL. Then why did you send this to a debian.org address? >     Start "bash", terminal with shell pops up. >     2. This does not work: > >     # Put the above commands into a script, say check.sh >   

Re: Strange behaviour from jobs -p in a subshell

2018-11-14 Thread Greg Wooledge
> >>> Consider the following script. While the 3 sleeps are running, both jobs > >>> -p and $(jobs -p) will print 3 PIDs. Once the 3 children are finished, [...] ... hey, I think I just figured out the GOAL! You want to run a whole bunch of jobs in parallel, but only 3 at a time. Right? There a

Re: Double substitution issue

2018-11-21 Thread Greg Wooledge
On Tue, Nov 20, 2018 at 08:16:47PM -0800, fulldec...@gmail.com wrote: > I have found a way to use double expansion, and of course this is not safe > in all contexts: > > from=1;to=3;eval echo {$from..$to} for ((i=from; i<=to; i++)); do ... done.

Re: URL-links not activated – Bash v. 4.4.23

2018-11-23 Thread Greg Wooledge
On Fri, Nov 23, 2018 at 02:21:04PM +0100, Ricky Tigg wrote: > To reproduce: on Linux with GUI in GUI terminal – e.g. gnome-terminal – > execute following command then attempt to click present URL links: > > $ rpm -qfi `which FBReader` > (...) > > Actual result: it fails. > > Yet while the follow

Re: $RANDOM not Cryptographically secure pseudorandom number generator

2018-12-03 Thread Greg Wooledge
On Mon, Dec 03, 2018 at 09:56:33AM -0500, Chet Ramey wrote: > There has to be a compelling reason to change this, especially at a point > so close to a major release. > > You might be expecting too much from bash's random number generator. Is > the problem that its period is at most 2**16? For its

Re: $RANDOM not Cryptographically secure pseudorandom number generator

2018-12-03 Thread Greg Wooledge
On Mon, Dec 03, 2018 at 05:31:18PM +0100, Ole Tange wrote: > Luckily I did not just assume that Bash delivers high quality random > numbers, but I read the source code, and then found that the quality > was low. I do not think must users would do that. You're correct. Most users would not have to

Re: your mail

2018-12-12 Thread Greg Wooledge
On Wed, Dec 12, 2018 at 05:36:26PM +0100, Valentin Bajrami wrote: > f3d0r4:~$ cd ../Nonexistingdir > bash: cd: ../Nonexistingdir: No such file or directory > ^C > ^C > cd Desktop/ > f3d0r4:~/Desktop$ What's in your PS1 and PROMPT_COMMAND variables? Have you set a DEBUG trap? Have you set an E

Re: Error on arithmetic evaluation of `~0`.

2018-12-20 Thread Greg Wooledge
On Wed, Dec 19, 2018 at 10:31:36PM -0500, Bize Ma wrote: > It is also interesting that this fails: > > var=hello; echo "${var[ ~0]}" > bash: var: bad array subscript > > Isn't `var[0]` valid and equivalent to `var` ? Yes, but ~0 is not 0. wooledg:~$ echo $(( ~0)) -1 The issue you're reporting

Re: Should [[ -v 1 ]] be supported?

2018-12-28 Thread Greg Wooledge
On Thu, Dec 27, 2018 at 08:57:12PM -0500, G. Branden Robinson wrote: > What is it you're trying to achieve? State your goal in terms that are > "SMART": > > (S)pecific > (M)easurable > (A)ttainable > (R)easonable > (T)imely For the record, I tried for approximately two years to get Peng Yu to st

Re: problem with bash script loading

2019-01-07 Thread Greg Wooledge
On Sat, Jan 05, 2019 at 08:28:45AM +, Paulo Nogueira wrote: > What occurred to me is the following: suppose a script s1 starts > being executed, by forking say, and then s1 is overwritten DON'T... DO... THAT. Problem solved.

Re: "return" should not continue script execution, even if used inappropriately

2019-01-07 Thread Greg Wooledge
On Mon, Jan 07, 2019 at 04:20:46PM +0700, Robert Elz wrote: > Date:Sun, 6 Jan 2019 16:58:59 -0600 > From:Dennis Williamson > Message-ID: > > > | You should be able to protect yourself from this by detecting if a script > | is not being sourced when it's intended

Re: [DOC] Incomplete explanation about the regex =~ operator

2019-01-08 Thread Greg Wooledge
On Tue, Jan 08, 2019 at 10:47:21AM +, gilaro wrote: > See also: Does bash support word boundary regular expressions? Short answer: No. Long answer: Bash's =~ operator uses Extended Regular Expressions (ERE), as implemented by your system's C library's regular expression engine. Your system m

Re: Sourcing a script from a pipe is not reliable

2019-01-10 Thread Greg Wooledge
On Thu, Jan 10, 2019 at 12:01:10AM -0800, don fong wrote: > but on my mac, adding the sleep makes it fail reliably on the first > iteration. > > on my linux machine, it seems to succeed reliably even with the sleep - as > expected. That's because the version of bash on Mac OS X is 3.2. Bash 3.2

Re: Sourcing a script from a pipe is not reliable

2019-01-10 Thread Greg Wooledge
On Thu, Jan 10, 2019 at 11:36:03AM -0800, Jeremy wrote: > Agreed there is no likelihood of a patch to 3.2. However, this version of > bash still has a significant presence in the wild and this bug is breaking > an installation script, so I am looking for a POSIX-compliant (and works > under Cygwin)

Re: Problem in var substitution with / and \

2019-01-14 Thread Greg Wooledge
On Mon, Jan 14, 2019 at 12:51:37PM +0100, Jean-François Berroyer wrote: > If a variable contains one '/' (or many) > and if this '/' is escaped with '\' by substitution mechanism > and if the escaped variable is concatenated with a string containing '/' as > prefix, and another string containing '/

Re: [DOC] Incomplete explanation about the regex =~ operator

2019-01-17 Thread Greg Wooledge
On Thu, Jan 17, 2019 at 07:53:09AM +0100, kevin wrote: > I looked at Greg Wooledge's site > <https://mywiki.wooledge.org/BashGuide/TestsAndConditionals#Conditional_Blocks_.28if.2C_test_and_.5B.5B.29>: > > >Since *[[* isn't a normal command (like [ is), but

Re: [bug-bash] $RANDOM not Cryptographically secure pseudorandom number generator

2019-01-21 Thread Greg Wooledge
On Sun, Jan 20, 2019 at 03:39:45PM +0100, Martijn Dekker wrote: > E.g. to create a random character string for a temporary > file name, you could do > > filename_suffix() { > chars=ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789 > length=${#chars} > for ((i=0; i<10; i++)

Re: "return" should not continue script execution, even if used inappropriately

2019-01-21 Thread Greg Wooledge
On Sun, Jan 20, 2019 at 05:43:04PM -0800, don fong wrote: > i don't see how this helps. the point is to have one file of code that > behaves differently depending on whether it's dotted in or executed at the > top level. https://mywiki.wooledge.org/BashFAQ/109

Re: ${p+\"$p\"}

2019-01-21 Thread Greg Wooledge
On Mon, Jan 21, 2019 at 09:14:26PM +0800, Dan Jacobson wrote: > So how am I to get > "A" > with bash? > > $ cat z > p=A > cat < ${p+\"$p\"} > ${p+"$p"} > EOF > $ bash z > \"A\" > A > $ dash z > "A" <=WANT THIS > A > $ bash --version > GNU bash, version 5.0.0(1)-release... So, if I'm readi

Re: ${b+s ''}

2019-02-19 Thread Greg Wooledge
On Sun, Feb 17, 2019 at 08:07:06PM -0500, Chet Ramey wrote: > On 2/16/19 11:38 AM, sunnycemet...@gmail.com wrote: > > I would like to include a null string as part of a parameter expansion word: > > > >> mapfile -t${bNullDelimited+d ''} > > > > When bNullDelimited is set, I expect this to expand

Re: tab and arrow keys

2019-02-19 Thread Greg Wooledge
On Tue, Feb 19, 2019 at 09:24:38AM -0500, Chet Ramey wrote: > On 2/19/19 3:24 AM, azad vishwakarma wrote: > > hi there > > while changing password with terminal/bash, it accepts tab and arrow keys > > along with characters,symbols and spacebar. But when we try to login into > > the system *"TAB and

Re: bash 5.0 dies with HISTSIZE=0

2019-02-21 Thread Greg Wooledge
On Thu, Feb 21, 2019 at 11:32:02AM +0100, Michael Albinus wrote: > PS: Could you pls give me a bug number or something like this, that I > can reference to? Bash doesn't use a formal bug tracking system. Chet manages it all by hand. Your best bet is to find the list archive copy of this thread,

Re: Please store source file name + line number for all functions defined whether or not bashdb is running.

2019-03-04 Thread Greg Wooledge
On Sat, Mar 02, 2019 at 08:47:43PM -0800, L A Walsh wrote: > hb=~law/bin (line#4) Well, that's just a syntax error. > if ! [[ $hb =~ $PATH ]]; then export PATH="$hb:$hl:$PATH"; fi What is the logic behind that regex check? It looks completely wrong. If the intent of this code is "check whether

Re: Bug: Bash forgets sourcefile and linenumber of read-in functions

2019-03-11 Thread Greg Wooledge
On Mon, Mar 11, 2019 at 01:15:16PM -0700, L A Walsh wrote: > 1) Where is it documented that if you export a function, the original > source location is thrown away by bash? It's not documented so much as blatantly obvious by looking at how it's implemented. wooledg:~$ export -f title wooledg:~$

Re: Bug: Bash forgets sourcefile and linenumber of read-in functions

2019-03-12 Thread Greg Wooledge
On Mon, Mar 11, 2019 at 02:26:20PM -0700, L A Walsh wrote: > How would that break compatibility? The same way shellshock did. A function exported by a parent bash process using format A could not be read by a child bash process expecting format B. Now, you may be thinking, "This makes no sense!

Re: "here strings" and tmpfiles

2019-03-19 Thread Greg Wooledge
On Mon, Mar 18, 2019 at 05:18:10PM -0400, Daniel Kahn Gillmor wrote: > strace -o tmp/bash.herestring.strace -f bash -c 'cat <<<"hello there"' > It turns out that this creates a temporary file, actually touching the > underlying filesystem: Yes, just like here documents do. And have always don

Re: "here strings" and tmpfiles

2019-03-19 Thread Greg Wooledge
On Tue, Mar 19, 2019 at 09:20:33AM -0400, Daniel Kahn Gillmor wrote: > On Tue 2019-03-19 08:25:50 -0400, Greg Wooledge wrote: > > On Mon, Mar 18, 2019 at 05:18:10PM -0400, Daniel Kahn Gillmor wrote: > >> strace -o tmp/bash.herestring.strace -f bash -c 'cat <<<

Re: "here strings" and tmpfiles

2019-03-20 Thread Greg Wooledge
On Wed, Mar 20, 2019 at 07:36:41AM -0400, Daniel Kahn Gillmor wrote: > How do you replicate 3<<<"$secret" with a pipeline? Not strictly a pipeline, but: 3< <(printf %s "$secret") This is actually preferred in many cases, because it doesn't add a newline. <<< always adds a newline to the result,

Re: "here strings" and tmpfiles

2019-03-20 Thread Greg Wooledge
On Wed, Mar 20, 2019 at 07:49:34AM +0700, Robert Elz wrote: > However, using files for here docs makes here docs unusable in a shell > running in single user mode with no writable filesystems (whatever is > mounted is read only, until after file system checks are finished). Meanwhile, proposals ba

Re: "here strings" and tmpfiles

2019-03-22 Thread Greg Wooledge
On Fri, Mar 22, 2019 at 10:28:52AM -0400, Chet Ramey wrote: > On 3/20/19 8:19 AM, Greg Wooledge wrote: > > > Even if Chet changed how here docs work in bash 5.1, nobody would > > be safe to use those features in their "I'm feeding a password with > > a here str

Re: Feature request or advice on implementation for buffering command output

2019-03-27 Thread Greg Wooledge
On Wed, Mar 27, 2019 at 12:49:45AM -0700, Anders Brujordet wrote: > Usecase: > You run a command, the output is displayed in your terminal. Now that you > see the output, you would like to grab say an ID from this output. Instead > of coping and pasting the output, I would like to be able to do som

Re: [A-Z], [:upper:]

2019-03-28 Thread Greg Wooledge
On Thu, Mar 28, 2019 at 09:30:43PM +0100, Norman H. Azadian wrote: > Description: > In version 4 [A-Z] is broken and [:upper:] works. > In version 5, the situation is reversed. > > Repeat-By: > foo=ABC ; echo ${foo%[A-Z]} ${foo%[:upper:]} You have two problems here. Well, fou

Re: [A-Z], [:upper:]

2019-03-29 Thread Greg Wooledge
> | And you forgot to quote. > > Really! That again! Here, unless one of A or B (or perhaps C, > though as that's supposed to be removed, it shouldn't matter) is in > IFS - in which case I think we'd be told - quoting makes no difference > at all. The example is clearly contrived just for t

Re: [A-Z], [:upper:]

2019-03-29 Thread Greg Wooledge
> | [A-Z] isn't safe to use unless ... > > That's true to an extent, but we know here that the intent is to > match 'C' which is between A and Z in every locale in the universe. > Variations on A might not be, variations on Z might not be, and there > might be more than just the upper case Engli

Re: Can not declare a local variable if an global ro-variable exists with the same name

2019-03-29 Thread Greg Wooledge
On Wed, Mar 27, 2019 at 02:06:51PM +0100, joerg...@snafu.de wrote: > If I declare a global read-only variable and I try to declare a local > variable with that name, I can not create > the local variable. > I expect that local variables can be declared independently for the > gl

Re: Feature request or advice on implementation for buffering command output

2019-04-08 Thread Greg Wooledge
On Fri, Apr 05, 2019 at 03:57:16PM -0700, L A Walsh wrote: > What would be wrong with doing something like: > > readarray -t last10< <(COMMAND |tail -10) > > That will put the last 10 lines of COMMAND_OUTPUT into > the array 'last10'. Now you can launch another command > to process that last

Re: "here strings" and tmpfiles

2019-04-08 Thread Greg Wooledge
On Sun, Apr 07, 2019 at 01:06:21PM -0700, L A Walsh wrote: > On 3/20/2019 5:19 AM, Greg Wooledge wrote: > > Just like that one time L. Walsh tried to write a bash boot script that > > used <() to populate an array, and it failed because she was running > > it too early i

Re: "here strings" and tmpfiles

2019-04-08 Thread Greg Wooledge
On Mon, Apr 08, 2019 at 10:53:46AM -0400, Chet Ramey wrote: > On 4/8/19 10:36 AM, Greg Wooledge wrote: > > > That's incorrect in this context. We're talking about boot scripts here, > > not interactive user shells. In boot scripts, on every operating system > &g

Re: bash 5: globstar (sometimes) no longer prints symlinks to directories

2019-04-08 Thread Greg Wooledge
On Mon, Apr 08, 2019 at 12:57:52PM -0400, Eli Schwartz wrote: > #bash pointed out to me that **/* will do what I want on both bash 4 and > bash 5, but I'm afraid I totally don't understand what the rules of > globstar are supposed to be, or whether changes to the output are > intended. The behavior

Re: "here strings" and tmpfiles

2019-04-09 Thread Greg Wooledge
On Tue, Apr 09, 2019 at 02:32:38PM +0700, Robert Elz wrote: > The idea is basically just to do > > var=$( cmd ) > > right? But without a fork. That's something that can be done today, > no new syntax needed (bash might even do it sometimes, I don't know, the > FreeBSD shell does.) wool

Re: "here strings" and tmpfiles

2019-04-09 Thread Greg Wooledge
On Tue, Apr 09, 2019 at 10:10:44PM +0800, konsolebox wrote: > @Chet, Isn't bash supposed to use named pipes alternatively, and > dynamically? Or does it just decide what to use based on the current > system? The second thing. On platform X, bash uses named pipes. On platform Y, bash uses /dev/f

Re: "here strings" and tmpfiles

2019-04-10 Thread Greg Wooledge
On Tue, Apr 09, 2019 at 04:48:30PM -0700, L A Walsh wrote: > > cp <(process) /tmp/foo > --- > *red face* I'd never tried to copy something that > looked like input redirection. My apologies on my misconception. One of the archetypal examples that we give when explaining process substitut

Re: "here strings" and tmpfiles

2019-04-10 Thread Greg Wooledge
On Tue, Apr 09, 2019 at 04:48:30PM -0700, L A Walsh wrote: > But the implementation of process substitution in bash > isn't implemented that way in the currently released version. It > uses a tmp file on a disk of fixed size to store *all* of the output > of the 'writer' before the reader is c

Re: Shell command history messing up when switching windows/slices in tmux

2019-04-10 Thread Greg Wooledge
On Wed, Apr 10, 2019 at 09:44:34AM +0200, Matej Vargovčík wrote: > I had a problem losing bash history when switching between terminals in > tmux. I reported the issue in tmux, but the developers have told me that > it's a bash problem and I should report it here. Please see this thread for > more

Re: "here strings" and tmpfiles

2019-04-10 Thread Greg Wooledge
On Wed, Apr 10, 2019 at 11:59:19AM -0400, Daniel Kahn Gillmor wrote: > If we look at the problem from the perspective of the risk of > herestring/heredoc content leaking to non-ephemeral storage, The content is already in the damned SHELL SCRIPT. How much more "non-ephemeral" can it get?

Re: "here strings" and tmpfiles

2019-04-11 Thread Greg Wooledge
On Thu, Apr 11, 2019 at 06:02:41AM +0200, Jason A. Donenfeld wrote: > what about internally treating "x < x"? Are these somehow not quite equivalent because x is in a subshell > in one but not the other, or something like that? cmd <<< string opens a temporary file for writing, dumps the string

Re: "here strings" and tmpfiles

2019-04-11 Thread Greg Wooledge
On Thu, Apr 11, 2019 at 09:01:50PM +0800, konsolebox wrote: > On Thu, Apr 11, 2019, 4:04 PM Andreas Schwab wrote: > > Do you have swap enabled? > > It's 2019. So... yes. Because everyone in 2019 has a laptop and therefore has swap enabled because it's used for hibernation. That was what you me

Re: feature request: allow shif [n] with n > $#

2019-04-15 Thread Greg Wooledge
On Sat, Apr 13, 2019 at 09:43:47AM +0200, Toralf Förster wrote: > Except, that I used the opposite: > > min_days=${1:-5} > min_hours=${2:-12} > min_compl=${3:-3500} > shift "$(( $# < 3 ? $# : 3 ))" > setupargs="$@" So... this user interface of yours. It looks someth

Re: feature request: allow shif [n] with n > $#

2019-04-15 Thread Greg Wooledge
On Mon, Apr 15, 2019 at 08:42:53AM -0400, Greg Wooledge wrote: > On Sat, Apr 13, 2019 at 09:43:47AM +0200, Toralf Förster wrote: > > Except, that I used the opposite: > > > > min_days=${1:-5} > > min_hours=${2:-12} > > min_compl=${3:-3500} &

Re: Segfault after many stackframes

2019-04-19 Thread Greg Wooledge
On Fri, Apr 19, 2019 at 10:21:00AM +0200, Ole Tange wrote: > Of course it is up to you, but if the current behaviour is a > controlled exit working the way it was designed, I find it odd that > there is no mention of it in the docs. Functions may be recursive. The FUNCNEST variable may be

Re: Bash-5.0 Official patch 7

2019-04-22 Thread Greg Wooledge
On Mon, Apr 22, 2019 at 12:54:28PM -0400, Dennis Clarke wrote: > I see these are all published in the gnu ftp server : > > https://ftp.gnu.org/pub/gnu/bash/bash-5.0-patches/ > > So I will try again from the sources but am curious if there is a definitive > list of dependencies that bash 5.0.7

Re: Bash-5.0 Official patch 7

2019-04-22 Thread Greg Wooledge
On Mon, Apr 22, 2019 at 01:21:38PM -0400, Dennis Clarke wrote: > I don't think bash 5 has hit Debian sid yet. It's not only in sid; it's also in buster. Here's the relevant excerpt from the changelog: bash (5.0-1) unstable; urgency=medium * New upstream release. -- Matthias Klose Mon, 14

Re: Arithmetic expansion with increments and output redirection

2019-04-24 Thread Greg Wooledge
On Wed, Apr 24, 2019 at 06:47:41AM -0600, Ian Neal wrote: > At what point is a subshell being invoked? There's no pipeline, command > substitution, coprocess, background process, or explicit () subshell here, > which are the only cases a subshell should be created. Otherwise, the > entire operation

Re: Arithmetic expansion with increments and output redirection

2019-04-24 Thread Greg Wooledge
On Wed, Apr 24, 2019 at 09:58:42AM -0400, Chet Ramey wrote: > The SVR4.2 Bourne shell, as another data point, behaves like bash. Since > it doesn't have arithmetic expansion, you have to use something it does > handle internally, like ${n:=2}. I don't know what ksh88, the other POSIX > historical

Re: "set -u" and empty arrays

2019-05-09 Thread Greg Wooledge
On Thu, May 09, 2019 at 01:07:16PM +0200, Ulrich Windl wrote: > Bash Version: 4.3 > Patch Level: 48 > Release Status: release > > Hi! > > Is this intended with "set -u": > # set -u > # declare -a INSTANCES > # echo ${INSTANCES[*]} > bash: INSTANCES[*]: unbound variable > # INSTANCES=() > # echo $

Re: Backslash mysteriously disappears in command expansion when unescaping would reference an existing file

2019-05-22 Thread Greg Wooledge
On Wed, May 22, 2019 at 05:25:43PM +0700, Robert Elz wrote: > Date:Tue, 21 May 2019 22:11:20 + > From:Charles-Henri Gros > Message-ID: > > > | The existence or not of the file should not have any effect. > > But it does, and is intended to. If the mattern m

Re: Possible bug in Bash Reference Manual - lists of commands

2019-05-22 Thread Greg Wooledge
On Wed, May 22, 2019 at 02:38:29PM +0800, Ralph Jensen wrote: > The Bash Reference Manual, Edition 5 and earlier versions define lists of > commands as follows: > > "A list is a sequence of one or more pipelines separated by one of the > operators ..." (Bash Reference Manual 3.2.3). > > Shouldn't

Re: Backslash mysteriously disappears in command expansion when unescaping would reference an existing file

2019-05-22 Thread Greg Wooledge
On Wed, May 22, 2019 at 05:34:22PM +, Charles-Henri Gros wrote: > On 5/22/19 5:43 AM, Greg Wooledge wrote: > > Standard disclaimers apply. Stop using unquoted variables and these > > bugs will stop affecting you. Nevertheless, Chet may want to take a > > peek. > &

Re: Backslash mysteriously disappears in command expansion when unescaping would reference an existing file

2019-05-22 Thread Greg Wooledge
On Wed, May 22, 2019 at 07:14:44PM +, Charles-Henri Gros wrote: > The file name is the regex (argument to "-e"), not the file "grep" > reads. I want to check that some text file contains a reference to a file. > > But it looks like this would work: > > for file in $(find ...); do grep -e "$(e

Re: Backslash mysteriously disappears in command expansion when unescaping would reference an existing file

2019-05-23 Thread Greg Wooledge
On Wed, May 22, 2019 at 10:23:04PM +, Charles-Henri Gros wrote: > But unfortunately, grep was just illustrative, I'm using another tool > that takes a regex but has no "-F" option 1. The questioner's first description of the problem/question will be misleading. 9. All examples given by the

Re: Wanted: better(more specific) error msgs?

2019-05-28 Thread Greg Wooledge
On Sat, May 25, 2019 at 06:21:27PM -0700, L A Walsh wrote: > Problem happened when I re-used a var that had earlier had the > integer property set on the variable. > > declare -i a=123 That's (part of) why I strongly recommend that nobody ever use that -i flag. > then later > a="▯" > -bash: ▯: s

Re: loadables/rm not POSIX compliant

2019-05-28 Thread Greg Wooledge
On Wed, May 29, 2019 at 02:04:10AM +1000, G. Branden Robinson wrote: > In fact, the bash-doc package contains dozens of examples. However, I > don't see anything named "rm". (I'm looking at bash-doc 5.0-4 in Debian > 10, "buster".) Looks like they're supposed to be in bash-builtins. wooledg:~$

Re: Code Execution in Mathematical Context

2019-06-04 Thread Greg Wooledge
On Tue, Jun 04, 2019 at 01:42:40PM +0200, Nils Emmerich wrote: > Configuration Information [Automatically generated, do not change]: > Machine: x86_64 > OS: linux-gnu > Compiler: gcc > Compilation CFLAGS: -g -O2 -Wno-parentheses -Wno-format-security > uname output: Linux VirtualBox 4.18.0-20-generi

Re: Code Execution in Mathematical Context

2019-06-06 Thread Greg Wooledge
that $((...)) is > parsed as if it was written > $(("...")) and therefore any single quotes inside the parentheses are > not special. But... On Tue, Jun 04, 2019 at 09:24:27AM -0400, Greg Wooledge wrote: > wooledg:~$ a=(foo bar baz) > wooledg:~$ i='$(date >&2)

Re: Arithmetic evaluation of negative numbers with base prefix

2019-06-17 Thread Greg Wooledge
On Mon, Jun 17, 2019 at 02:30:27PM +0100, Jeremy Townshend wrote: > In the meantime it would seem cautionary to advise against the pitfall of > using base# prefixed to variables (contrary to > mywiki.wooledge.org/ArithmeticExpression) unless you can be confident that > they will never be decremente

Re: Arithmetic evaluation of negative numbers with base prefix

2019-06-18 Thread Greg Wooledge
On Tue, Jun 18, 2019 at 10:27:48AM -0400, Chet Ramey wrote: > $ ksh93 -c 'echo ${.sh.version}' > Version ABIJM 93v- 2014-09-29 > $ ksh93 -c 'echo $(( 10# ))' > ksh93: 10# : arithmetic syntax error I guess most Linux distributions are not shipping the 2014 version of ksh93 yet...? wooledg:~$ ksh

Re: How to tell Bash multiple values are success?

2019-06-19 Thread Greg Wooledge
On Wed, Jun 19, 2019 at 11:01:46AM -0400, Jeffrey Walton wrote: > if dnf -y update &>/dev/null > then > echo "Upgraded system" > else > echo "Failed to upgrade system" > exit 1 > fi > > The problems seems to be 0, 100 and 200 are success. When updates are >

Re: continued alias problem -- some work, some don't, why?

2019-07-09 Thread Greg Wooledge
On Mon, Jul 08, 2019 at 03:30:47PM -0700, L A Walsh wrote: > alias my='declare ' > alias Export='-x ' > alias Map='-A ' > alias Int='-i ' > > my Export Map Int e=([one]=1) > -bash: declare: `-x': not a valid identifier > -bash: declare: `-A': not a valid identifier > -bash: declare: `-i': not

Re: alias problem -- conflict found

2019-07-10 Thread Greg Wooledge
On Tue, Jul 09, 2019 at 08:24:30PM -0700, L A Walsh wrote: > > On Mon, Jul 08, 2019 at 03:30:47PM -0700, L A Walsh wrote: > >> alias my='declare ' Export='\-x ' Map='-A ' Int='-i ' > All of them are shorter than their original forms By what metric is "Export" shorter than "-x", or "Map" sh

Re: bash bug with root account

2019-07-10 Thread Greg Wooledge
On Wed, Jul 10, 2019 at 09:15:14AM -0400, Chet Ramey wrote: > On 7/10/19 4:01 AM, westlake wrote: > > If a normal user types "su -l" and issues this "ls" statement, > This account has the `extglob' shell option enabled. "su -l" gives you a login shell, so this instance of bash is reading /etc/prof

Re: alias problem -- conflict found

2019-07-10 Thread Greg Wooledge
On Wed, Jul 10, 2019 at 10:29:14PM +0700, Robert Elz wrote: > From:L A Walsh > | Functions can't process their arguments in the current scope. > > I have no idea what you're getting at there. She wants something like Tcl's [uplevel] command, most likely. http://www.tcl.tk/man/tcl8

Re: background, pipeline, hang

2019-07-12 Thread Greg Wooledge
On Fri, Jul 12, 2019 at 04:00:57PM +0200, Mike Jonkmans wrote: > uname output: Linux sint 4.15.0-54-generic #58-Ubuntu SMP Mon Jun 24 10:55:24 > UTC 2019 x86_64 x86_64 x86_64 GNU/Linux (Why are you reporting problems on an Ubuntu system on a debian.org mailing list?) > Repeat-By: > : | : |

Re: alias problem -- conflict found

2019-07-15 Thread Greg Wooledge
On Fri, Jul 12, 2019 at 07:22:25PM -0700, Eduardo Bustamante wrote: > Can we please STOP this thread? What is the point? Linda will never > change her mind. You all are just wasting time and electricity. > > (and spamming the mailing list with this non-sense). https://xkcd.com/386/

Re: The text duplication when you type something too long.

2019-07-16 Thread Greg Wooledge
On Tue, Jul 16, 2019 at 01:15:50PM +0700, ChanakanZ Tech wrote: > Description: > When the text in line got too long, the line duplicated into two > > Repeat-By: > type something very long in it. It gonna duplicated into another > one when it long than a terminal width. PS: Sorry fo

Re: Unexpected result of array assignment

2019-07-18 Thread Greg Wooledge
On Thu, Jul 18, 2019 at 10:58:52AM +0200, Henning wrote: > On 18/07/2019 03:16, Darren 'Tadgy' Austin wrote: > > > foo=(["key"]="${foo["key"]} value2") > > using eval shoud also succeed, even for older bash: > > eval 'foo=(["key"]="'"${foo["key"]}"' value2")' If you just want to

Re: leaks fd for internal functions but not external command

2019-07-23 Thread Greg Wooledge
On Tue, Jul 23, 2019 at 04:40:03PM +0100, Sam Liddicott wrote: > Is using {xxx}>... suppose to give me a file handle I can use as I wish (as > you say), or not? > > Using explicit descriptors e.g. 10>... behaves consistently whether the the > command is internal or external. > > Having bash alloc

Re: [PATCH] Fix \H: Use getaddrinfo to get full hostname

2019-07-24 Thread Greg Wooledge
On Wed, Jul 24, 2019 at 04:38:06PM +0200, Thomas Deutschmann wrote: > Can you tell me more about your system and how you (your administrator) > set up your system so that hostname will return FQDN? It's common outside the Linux world. # hostname minea.eeg.ccf.org # uname -a HP-UX minea B.11.11 U

Re: [PATCH] Fix \H: Use getaddrinfo to get full hostname

2019-07-24 Thread Greg Wooledge
On Wed, Jul 24, 2019 at 05:23:27PM +0200, Thomas Deutschmann wrote: > On 2019-07-24 16:46, Greg Wooledge wrote: > >> I hope you are not talking about putting FQDN into a file which is > >> expecting hostname only... > > > > Yes, many people do precisely that. Th

Re: expression evaluation problem

2019-07-24 Thread Greg Wooledge
On Wed, Jul 24, 2019 at 09:39:46AM -0700, L A Walsh wrote: > str='cf80' > v=960 uxtra=1 c=0 Irrelevant alias shenanigans omitted. These are your variables. > # In evaluating this expression: > ((v = v | ( uxtra>=++c ? ((0x${str:2*c:2}) & 63) << (6*(uxtra-c)) : 0 ))) > > > I get 985 and not

Re: expression evaluation problem

2019-07-24 Thread Greg Wooledge
On Wed, Jul 24, 2019 at 11:43:11AM -0700, L A Walsh wrote: > Those aren't my variables. > If you assign the integer attribute to a variable it isn't the same > as when you don't. In this case it *is*, because everything is being fed to an arithmetic command anyway. Simplifying the bug report as m

Re: expression evaluation problem

2019-07-25 Thread Greg Wooledge
On Thu, Jul 25, 2019 at 10:29:08AM -0700, L A Walsh wrote: > On 2019/07/24 11:49, Greg Wooledge wrote: > > $((expression)) > > > >The expression is treated as if it were within double quotes, > I didn't use $((...)), I'd put the wh

Re: Have var+func sourced in a subroutine but they don't seem to end up in same scope

2019-07-29 Thread Greg Wooledge
On Sun, Jul 28, 2019 at 11:25:24PM -0700, L A Walsh wrote: > util_fn () { > > declare [-x] foo=1 > declare [-x] bar=${foo}2 > > real_util_fn() { > makes use of bar to get 'foo2' > } > > real_util_fn "$@" > } You do realize that despite your indentation, and despite the definition

Re: x[

2019-07-29 Thread Greg Wooledge
On Mon, Jul 29, 2019 at 01:09:28PM -0400, Eli Schwartz wrote: > On 7/29/19 1:01 PM, Clint Hepner wrote: > > The ``[`` begins a valid shell pattern, so the parser continues to > > accept input until the closing ``]`` is found. Pathname expansion > > (apparently) does not apply to the first "argument

Re: How does this wait -n work to cap parallelism?

2019-07-29 Thread Greg Wooledge
On Mon, Jul 29, 2019 at 07:12:42PM +0100, Earnestly wrote: > #!/usr/bin/env bash > > # number of processes to run in parallel > num_procs=5 > > # function that processes one item > my_job() { > printf 'Processing %s\n' "$1" > sleep "

Re: Setting nullglob causes variables containing backslashes to be expanded to an empty string

2019-08-06 Thread Greg Wooledge
On Tue, Aug 06, 2019 at 06:18:27PM +, Mohamed Akram wrote: > Bash version: GNU bash, version 5.0.7(1)-release (x86_64-apple-darwin18.5.0) > > Example: > > shopt -s nullglob > a='\x30' > echo $a > > Expected output: > > \x30 > > Actual output: > Also happens in bash 5.0 on Debian GNU/Linu

Re: Filename expansion bug

2019-08-08 Thread Greg Wooledge
On Thu, Aug 08, 2019 at 04:33:16PM +0200, Janek Mi wrote: > For some time in my scripts I was using something like this: > > ```shell > #!/usr/bin/env bash > shopt -s failglob > command="echo xyz\(\)" > $command > ``` > > And it was working fine. But somewhere between bash version 4 and 5 I > rea

Re: Documentation about destroying an array element

2019-08-15 Thread Greg Wooledge
On Thu, Aug 15, 2019 at 12:37:01PM +0300, jarno.s...@saunalahti.fi wrote: > https://www.gnu.org/software/bash/manual/html_node/Arrays.html tells > "unset name[subscript] destroys the array element at index subscript." > > But if there is a file named names, nameu ,nameb, namec, namer, namei, namep

Re: Associative array entries order differs from declaration

2019-08-15 Thread Greg Wooledge
On Thu, Aug 15, 2019 at 05:26:03PM +0200, Léa Gris wrote: > Is there a way to control the order of entries in an associative array? No. > What rules applies to the order of entries? None. If you require both an associative array and an ordered list, then you will need two different data structu

Re: declare -g reports as invalid option on MacOS (10.14.6) Bash (5.0.11)

2019-09-03 Thread Greg Wooledge
On Fri, Aug 30, 2019 at 06:03:37PM -0600, Ray Sutton wrote: > The issue is on a late 2013 MBP running MacOS 10.14.6 and > bash -version reports 5.0.11(1)-release (x86-64-apple-darwin18.6.0) > > The error is occuring in my .bash_profile and reports as > > -bash: declare: -g: invalid option You p

Re: Incorrect example for `[[` command.

2019-09-20 Thread Greg Wooledge
On Fri, Sep 20, 2019 at 01:40:00PM +0800, hk wrote: > Description: > On section 3.2.4.2 of Bash Reference Manual, the example on* > [[...]]* (page 13 in the PDF) is incorrect. Specifically, the example say *[[ > $line =~ [[:space:]]*?(a)b ]]* will match values like *'aab'* and* > 'aab*

Re: Wrong command option in the manual examples

2019-09-23 Thread Greg Wooledge
On Mon, Sep 23, 2019 at 09:02:47PM +0700, Robert Elz wrote: > There is no real standard for this - NetBSD has deprecated the -depth > operator (which never really was one) and replaced it by a -d option > which makes much more sense (-depth never really was the right way to > do it). -depth (the o

Re: shebang-less script execution not resetting some options

2019-10-01 Thread Greg Wooledge
On Tue, Oct 01, 2019 at 04:14:00AM -0700, L A Walsh wrote: > On 2019/09/30 14:39, Grisha Levit wrote: > > A few of the recently-added shopt options aren't getting reset when > > running a shebang-less script, this should fix it up: > > > Suppose the shebang-less script is being run by an earlier

Re: shebang-less script execution not resetting some options

2019-10-02 Thread Greg Wooledge
On Wed, Oct 02, 2019 at 03:11:18AM -0700, L A Walsh wrote: > > Bash allows a child of itself (a subshell) to read the commands. > > GNU find -exec uses /bin/sh to run it. > > zsh and csh both use /bin/sh to run it, I think. > So if a user has 'rbash' in /etc/passwd, they might get a real shell

<    8   9   10   11   12   13   14   15   16   17   >