Re: Assignment to RO variable

2023-08-16 Thread Greg Wooledge
On Tue, Aug 15, 2023 at 11:24:31PM -0500, Dennis Williamson wrote: > Your use of colon as a comment character is confusing. They're running with set -x, so presumably they used those : commands to mark the set -x output with various labels. Which seems nominally clever, except they didn't *show*

Re: using exec to close a fd in a var crashes bash

2023-08-19 Thread Greg Wooledge
On Sat, Aug 19, 2023 at 01:37:31PM -0400, jleivent wrote: > Repeat-By: > > exec {foo}>/tmp/foo > exec "${foo}"<&- Remove the quotes and the $ and it should work. exec {foo}<&- The way you've got it is essentially: exec "$foo" <&- This does't make bash "crash". It'

Re: using exec to close a fd in a var crashes bash

2023-08-22 Thread Greg Wooledge
On Tue, Aug 22, 2023 at 02:59:14PM -0400, Dale R. Worley wrote: > The "{var}>..." mechanism *assigns* to $var, rather than > taking its existing value. ... oh. Well, today I learned something. Excuse me now, while I go and close several open FDs in the shell where I tested something the other da

Re: using exec to close a fd in a var crashes bash

2023-08-22 Thread Greg Wooledge
On Wed, Aug 23, 2023 at 12:05:42PM +1000, Martin D Kealey wrote: > On Wed, 23 Aug 2023, 05:29 Greg Wooledge, wrote: > > > Excuse me now, while I go and close several open FDs in the shell where > > I tested something the other day, which I had no idea were left open. > &

Re: using exec to close a fd in a var crashes bash

2023-08-23 Thread Greg Wooledge
On Wed, Aug 23, 2023 at 09:50:36AM -0400, Zachary Santer wrote: > From the NEWS file [1]: > > o. The new `varredir_close' shell option causes bash to automatically close >file descriptors opened with {var}redirection unless they're arguments to the `exec' builtin. Hmm, interesting. > $ s

Re: Some incorrect behaviour for BASH arrays

2023-08-31 Thread Greg Wooledge
On Thu, Aug 31, 2023 at 04:13:09PM +0100, Kerin Millar wrote: > This script is a mess because its functions begin by defining RESULT as an > ordinary, non-array variable (if not yet declared). > > $ RESULT='string' > $ declare -p RESULT # not yet an array variable > declare -- RESULT='string' >

Re: bug attached

2023-08-31 Thread Greg Wooledge
On Thu, Aug 31, 2023 at 10:38:55PM +0300, queency3 jones wrote: > > > function sub { aa=8;return_value=$aa; } > > > function sub { aa=8; } > > > > > > function main { aa=3;sub;aa=$(($aa+1));printf "$aa\n"; } > i don't think that main is significant when it declared in "Bash" but even > though, > i

Re: set -x vs. n=($@)

2023-09-03 Thread Greg Wooledge
On Sun, Sep 03, 2023 at 08:39:25PM +0200, alex xmb ratchev wrote: > On Sun, Sep 3, 2023, 12:08 Dan Jacobson wrote: > > > It's not fair: > > set -x a b c > > > > you may want -v *Sigh* No. set -v shows lines as they are being READ by the shell. set -x shows commands as they are being EXECUTED.

Re: Warn upon "declare -ax"

2023-09-05 Thread Greg Wooledge
On Tue, Sep 05, 2023 at 05:09:52PM +0200, Andreas Kähäri wrote: > On Tue, Sep 05, 2023 at 04:04:50PM +0200, alex xmb ratchev wrote: > > On Mon, Sep 4, 2023, 15:19 Kerin Millar wrote: > > > Curiously, ARRAY_EXPORT can be defined in config-top.h. It's probably safe > > > to say that nobody uses it (

Re: [PATCH] printf: add %#s alias to %b

2023-09-06 Thread Greg Wooledge
On Wed, Sep 06, 2023 at 02:13:44AM +, William Bader wrote: > Has bash ever had a change before that would break valid scripts? Yes. Many times, sadly. Most recently, bash 5.2 introduced some changes to how associative array indexes are handled, which will break backward compatibility in seve

Re: Prompt messed up if PS1 contains ANSI escape sequences

2023-09-07 Thread Greg Wooledge
On Thu, Sep 07, 2023 at 03:46:23PM +0200, Gioele Barabucci wrote: > On 07/09/23 15:00, alex xmb ratchev wrote: > > u have to \[ esc-seq \] > > eg inside \[ and \] > > > > PS1=$'\u\[\e[1m\]\h\[\e[0m- ' > > > > should display hostname bold > > Thanks for the suggestion, but adding \] does not real

Re: Prompt messed up if PS1 contains ANSI escape sequences

2023-09-07 Thread Greg Wooledge
On Thu, Sep 07, 2023 at 04:03:39PM +0200, Gioele Barabucci wrote: > The following snippet shows that, even with the final \], Bash produces the > same erroneous output and miscalculates the cursor position (it just needs a > longer prompt): > > $ long_name="$(printf 'abcdef0123456789/%.0s' {0.

Re: bug:

2023-10-03 Thread Greg Wooledge
On Tue, Oct 03, 2023 at 12:54:45PM +, queency jones via Bug reports for the GNU Bourne Again SHell wrote: > BASH_VERSION='5.1.4(1)-release'PRETTY_NAME="Debian GNU/Linux 11 (bullseye)"no > compile needed > i made a fifo file by typing: mkfifo gdbout.fifo > i coded a resource file named  : comm

Re: error message lacks useful debugging information

2023-10-04 Thread Greg Wooledge
On Wed, Oct 04, 2023 at 08:05:41PM -0400, Dave Cigna via Bug reports for the GNU Bourne Again SHell wrote: > Attempting to tun an executable file (not a bash script) with the following > command: > > ./Candle > > the following error message is reported by bash: > > bash: ./Candle: cannot execut

Re: error message lacks useful debugging information

2023-10-05 Thread Greg Wooledge
On Thu, Oct 05, 2023 at 07:04:26AM +0200, Phi Debian wrote: > Since we are on the error path (not the perf path) may be the shell could > go the extra miles and try some more diag, has it does for shebang, on > ENOENT, the shell could try to open the a.out, if OK try some other > euristics, [...]

Re: "here document" causing failures. Implementation is inconsistent and not documented.

2023-10-10 Thread Greg Wooledge
On Wed, Oct 11, 2023 at 11:56:42AM +1100, Jim McD wrote: > Bug: > Trailing white space after the delimiting tag cause the here document to > fail with an error like > /./: line : warning: here-document at line > delimited by end-of-file (wanted `msg_end')Trailing white > space/ > > Trailing white

Re: variable set in exec'ing shell cannot be unset by child shell

2023-10-13 Thread Greg Wooledge
On Fri, Oct 13, 2023 at 02:21:59PM -0400, Dale R. Worley wrote: > I was too lazy to chew through your example, but I coded an instance of > your description (above), and it does not show the dubious behavior that > you report. Specifically, > > $ bash -version > GNU bash, version 5.1.0(1)

Re: variable set in exec'ing shell cannot be unset by child shell

2023-10-14 Thread Greg Wooledge
On Sat, Oct 14, 2023 at 12:55:21PM -0400, Ti Strga wrote: > it's just the "[[ -v > foo ]]" tests to see where along the cloning process we are. *Shudder* I foresee so much more pain in your future. Seriously, this is going to blow up in your face at some point. -v peeks into some incredibly dar

Re: wrong variable name in error message about unbound variable?

2023-10-17 Thread Greg Wooledge
On Tue, Oct 17, 2023 at 04:46:22AM +0200, Christoph Anton Mitterer wrote: > But why does it even try to evaluate the subscript "key" as arithmetic > expression? Because that's how indexed arrays work. Everything inside the square brackets is an arithmetic expression, and in an arithmetic context,

Re: bash tries to parse comsub in quoted PE pattern

2023-10-18 Thread Greg Wooledge
On Wed, Oct 18, 2023 at 08:19:35AM -0400, Zachary Santer wrote: > On Tue, Oct 17, 2023 at 5:56 PM Emanuele Torre > wrote: > > > bash-5.1$ letters=( {a..z} ); echo "${letters["{10..15}"]}" > > k l m n o p > > > > Then there's the question "Was that even supposed to work like that?" This

Re: bash tries to parse comsub in quoted PE pattern

2023-10-18 Thread Greg Wooledge
On Wed, Oct 18, 2023 at 09:39:36AM -0400, Zachary Santer wrote: > I guess I still want to hear about "${#@}" and $[ ]. $[ ] is officially deprecated, and users are advised to stop using it. It was originally going to be the syntax for arithmetic expansion, and made it as far as some POSIX rough d

Re: BUG: Colorize background of whitespace

2023-10-25 Thread Greg Wooledge
On Wed, Oct 25, 2023 at 10:29:32AM +0200, Holger Klene wrote: > Description: > The initial bash background is hardcoded to some default (e.g. black) and > cannot be colorized by printing "transparent" tabs/newlines with > ANSI-ESC-codes. > Only after a vertical scrollbar appears, the whitespace b

Re: BUG: Colorize background of whitespace

2023-10-25 Thread Greg Wooledge
On Wed, Oct 25, 2023 at 02:48:20PM +, David wrote: > On Wed, 25 Oct 2023 at 11:51, Greg Wooledge wrote: > > On Wed, Oct 25, 2023 at 10:29:32AM +0200, Holger Klene wrote: > > > Repeat-By: > > > run the following command line: > > > clear; seq 50; printf

Re: Regex: A case where the longest match isn't being found

2023-10-26 Thread Greg Wooledge
On Thu, Oct 26, 2023 at 10:50:13AM -0700, Dan Bornstein wrote: > I found a case where the regex evaluator doesn't seem to be finding the > longest possible match for a given expression. The expression works as > expected on an older version of Bash (3.2.57(1)-release > (arm64-apple-darwin22)).

Re: nullglob is documented incorrectly

2023-11-06 Thread Greg Wooledge
On Mon, Nov 06, 2023 at 08:56:11AM -0500, Chet Ramey wrote: > The null string (NULL) and the empty string ("") are not the same thing. If this is true, then the man page has many inconsistencies that need to be cleared up. For example, in the definition of PATH: PATH The search path for

Re: Idea: jobs(1) -i to print only :%ID:s

2023-11-09 Thread Greg Wooledge
On Thu, Nov 09, 2023 at 08:09:23PM +0100, Steffen Nurpmeso wrote: > j() { > local j= a=${AWK:-awk} > [ $# -gt 0 ] && j='&& $2 !~ /(^| )('$(echo "$@" | tr ' ' '|')')( |$)/' > j=$(jobs -l | $a -F '[][]' '/^[[]/'"$j"'{print "%" $2}{next}') > echo $j > } Classic code injection vuln

Re: Idea: jobs(1) -i to print only :%ID:s

2023-11-09 Thread Greg Wooledge
On Thu, Nov 09, 2023 at 10:17:35PM +0100, Andreas Schwab wrote: > On Nov 09 2023, Greg Wooledge wrote: > > > re='^\[([0-9]+)\]' > > jobspecs=() > > while IFS= read -r line; do > > if [[ $line =~ $re ]]; then > > jobs

Re: Idea: jobs(1) -i to print only :%ID:s

2023-11-10 Thread Greg Wooledge
On Fri, Nov 10, 2023 at 06:59:10PM +0100, Steffen Nurpmeso wrote: > Sequences are also bash-only (though seq(1) is > everywhere). It most definitely is *not* everywhere. It's part of GNU coreutils, and is generally not present on any system that does't use those (BSDs and commercial Unixes for ex

Re: Idea: jobs(1) -i to print only :%ID:s

2023-11-10 Thread Greg Wooledge
On Fri, Nov 10, 2023 at 10:54:52AM -0800, Eric Pruitt wrote: > > A seq command appeared in Version 8 AT&T UNIX. This version of seq > > appeared in NetBSD 3.0 and was ported to OpenBSD 7.1. Ah, I'm a year and a half behind. OpenBSD 7.1 was released April 2022.

Re: the portability of seq(1) (was: Idea: jobs(1) -i to print only :%ID:s)

2023-11-10 Thread Greg Wooledge
On Fri, Nov 10, 2023 at 01:09:29PM -0600, G. Branden Robinson wrote: > At 2023-11-10T10:54:52-0800, Eric Pruitt wrote: > > From _seq(1)_ on FreeBSD: > > > > > The seq command first appeared in Version 8 AT&T UNIX. A seq command > > > appeared in NetBSD 3.0, and was ported to FreeBSD 9.0. This comm

Re: posix command search and execution

2023-11-11 Thread Greg Wooledge
On Sat, Nov 11, 2023 at 09:14:41AM +0100, Mike Jonkmans wrote: > On Fri, Nov 10, 2023 at 08:07:31PM -0500, Chet Ramey wrote: > > On 11/9/23 11:17 AM, Mike Jonkmans wrote: > > > On Thu, Nov 09, 2023 at 10:12:06PM +0700, Robert Elz wrote: > > > > > > On Ubuntu 22.04 `getconf path' returns /bin:/usr/

Re: Command hangs when using process substitution

2023-11-18 Thread Greg Wooledge
ecord, here's what processes are running on the terminal while it's in the "hanging" state: unicorn:~$ ps f -ft pts/28 UID PIDPPID C STIME TTY STAT TIME CMD greg 1082506 1082504 0 09:21 pts/28 Ss 0:00 bash greg 1082862 1082506 0 09:35 pts/28

Re: Missing documentation "-bash_input"

2023-11-28 Thread Greg Wooledge
On Tue, Nov 28, 2023 at 10:33:20PM +, Klaus Frank wrote: > sorry, but this is not true, I can clearly see that it exists. It may be an > distro addition though. Is it specific to ArchLinux? Here's what I get on Debian: unicorn:~$ bash -bash_input foobar -c 'read; declare -p REPLY' bash: -_: i

Re: Missing documentation "-bash_input"

2023-11-28 Thread Greg Wooledge
On Wed, Nov 29, 2023 at 12:37:55AM +, Klaus Frank wrote: > One thing though, I probably should already know that, but why is a $0 > needed even though a command was already specified? Shouldn't the command > itself be $0? It's simply how sh -c has always worked. The first argument after -c is

Re: bash encountered a coredump issue with stepping on memory

2023-12-06 Thread Greg Wooledge
On Wed, Dec 06, 2023 at 05:28:19PM +0800, wang yuhang via Bug reports for the GNU Bourne Again SHell wrote: > When the for loop reaches env, the values of each env are: > [...] > (gdb) p env[16] > $21 = 0x7ffce3c2e25a "DIRNAME_ALIAS" > (gdb) p env[17] > $22 = 0x7ffce3c2e279 "PID=" The missi

Re: $((expr)) allows the hexadecimal constant "0x"

2023-12-11 Thread Greg Wooledge
On Tue, Dec 12, 2023 at 12:10:02AM +0900, Koichi Murase wrote: > https://lists.gnu.org/archive/html/bug-bash/2019-06/threads.html#00039 Four years later, i=$(( ${i%%[!+-]*}10#${i#[-+]} )) is still horrible. Well, to be fair, five years since the original suggestion

Re: Add example of bind readline-command-line

2023-12-12 Thread Greg Wooledge
On Tue, Dec 12, 2023 at 10:06:49PM +0800, Dan Jacobson wrote: > bash man page says > -v Display readline variable names and values in such a way > that they can be re-read. > Perhaps add an example of rereading via the bind command: The man page also include

Re: Unexpected Quick Substitution in string literals

2023-12-13 Thread Greg Wooledge
On Wed, Dec 13, 2023 at 10:50:16AM +0530, Sundeep Agarwal wrote: > $ echo "fig > ^mango" > bash: :s^mango": substitution failed I can confirm this happens in every version of bash, at least back to bash-2.05b which is as far as I can go, but only when history expansion is enabled (set -H or set -o

Re: funsub questions

2023-12-13 Thread Greg Wooledge
On Wed, Dec 13, 2023 at 08:50:48PM -0500, Zachary Santer wrote: > Would there be a purpose in implementing ${< *file*; } to be the equivalent > of $(< *file* )? Does $(< *file* ) itself actually fork a subshell? $(< file) does indeed fork. The only difference between $(< file) and $(cat file) is

Re: funsub questions

2023-12-13 Thread Greg Wooledge
On Thu, Dec 14, 2023 at 02:39:04AM +, Kerin Millar wrote: > On Wed, 13 Dec 2023 21:17:05 -0500 > Greg Wooledge wrote: > > > On Wed, Dec 13, 2023 at 08:50:48PM -0500, Zachary Santer wrote: > > > Would there be a purpose in implementing ${< *file*; } to be the

Re: funsub questions

2023-12-13 Thread Greg Wooledge
On Wed, Dec 13, 2023 at 10:48:59PM -0500, Zachary Santer wrote: > On Wed, Dec 13, 2023 at 9:17 PM Greg Wooledge wrote: > > If you'd like to read the contents of a file into a variable, the > > "read" and "readarray" (aka "mapfile") builtins are u

Re: funsub questions

2023-12-14 Thread Greg Wooledge
On Thu, Dec 14, 2023 at 04:44:07AM +, Kerin Millar wrote: > On Wed, 13 Dec 2023 23:16:11 -0500 > Zachary Santer wrote: > > > On Wed, Dec 13, 2023 at 11:06 PM Greg Wooledge wrote: > > > Is that on a system that lacks a process manager? Something like > > > &

Re: Unexpected Quick Substitution in string literals

2023-12-14 Thread Greg Wooledge
On Thu, Dec 14, 2023 at 09:41:17AM +0530, Sundeep Agarwal wrote: > Thanks for the correction on my second example. I had assumed ^ wasn't > special inside double quotes since the documentation mentions only the ! > character for history expansion ( > https://www.gnu.org/software/bash/manual/bash.ht

Re: Multi-line PS1 color disappearance problem

2023-12-22 Thread Greg Wooledge
On Fri, Dec 22, 2023 at 07:25:30AM +, email--- via Bug reports for the GNU Bourne Again SHell wrote: > On 2023-12-21 17:32, Alex Ratchev wrote: > > > do u really PS1=\[\033 etc ? > > > > try PS1='\[\e...' > > > > in ' quotes > > I forgot quotes from the email. But I did not know that '\e'

Re: mapfile weirdness ^@ is added it would seem if output is quoted

2024-01-01 Thread Greg Wooledge
On Mon, Jan 01, 2024 at 04:38:20PM -0500, Federer Fanatic wrote: > Consider the following: > > shopt -s extdebug > mapfile -d" " < <(declare -F Results in the array MAPFILE having 3 entries with '2' entry containing the > filename > of bash function initial defining line I don't think this is co

Re: document that read built-in can't return zero-length string in the middle of input

2024-01-11 Thread Greg Wooledge
On Thu, Jan 11, 2024 at 09:29:03AM -0500, Chet Ramey wrote: > The read builtin skips over NUL characters because you can't store them > as part of the value of a shell variable. That seems obvious. I would argue that it's not obvious at all when using -N. The help text for -N says "return only af

Re: document that read built-in can't return zero-length string in the middle of input

2024-01-11 Thread Greg Wooledge
On Fri, Jan 12, 2024 at 01:29:19AM +0100, Ángel wrote: > One might say "reading exactly nchars characters into the name", I would still find that confusing. What actually counts is how many characters are *stored* in the variable, not how many characters are *read* from the input. > but > given

Re: document that read built-in can't return zero-length string in the middle of input

2024-01-11 Thread Greg Wooledge
On Thu, Jan 11, 2024 at 08:02:04PM -0500, Greg Wooledge wrote: > And this for the help text: > > -N nchars return only after storing exactly NCHARS characters, unless >EOF is encountered or read times out, ignoring any NUL or >delimiter chara

Re: document that read built-in can't return zero-length string in the middle of input

2024-01-12 Thread Greg Wooledge
On Fri, Jan 12, 2024 at 03:26:31PM +0700, Robert Elz wrote: > Date:Thu, 11 Jan 2024 20:02:04 -0500 > From: Greg Wooledge > Message-ID: > > | What actually counts is how many > | characters are *stored* in the variable, not how many characte

Re: document that read built-in can't return zero-length string in the middle of input

2024-01-12 Thread Greg Wooledge
On Sat, Jan 13, 2024 at 02:06:08AM +0700, Robert Elz wrote: > Date:Fri, 12 Jan 2024 07:15:35 -0500 > From: Greg Wooledge > Message-ID: > > | This was one of the things I tested: > > Perhaps intended to, but didn't, or not in this example:

Re: ./script doesn't work in completion function

2024-01-22 Thread Greg Wooledge
On Mon, Jan 22, 2024 at 12:17:12PM +0200, Oğuz wrote: > On Monday, January 22, 2024, Martin D Kealey > wrote: > > > > You seem to have created an invalid executable. It seems that scripts > > without a #! can only be run with help from the debugger library > > > > Hi Martin, POSIX shells interpre

Re: Path of exported variable not set as source

2024-01-26 Thread Greg Wooledge
On Fri, Jan 26, 2024 at 03:28:11PM +0200, Ricky Tigg wrote: > $ export EDITOR='/usr/bin/nano' && source $HOME/.bashrc > $ echo $EDITOR > /usr/bin/vim > > Expected: Latest command's output to be "/usr/bin/nano" instaed of > "/usr/bin/vim". It's really unclear to me why you expected this. You're c

Re: wait -n misses signaled subprocess

2024-01-28 Thread Greg Wooledge
On Sun, Jan 28, 2024 at 10:26:27PM -0500, Dale R. Worley wrote: > The man page doesn't make clear that if you don't specify "-n" and do > supply ids and one of them has already terminated, you'll get its status > (from the terminated table); the wording suggests that "wait" will > always *wait for*

Re: wait -n misses signaled subprocess

2024-01-29 Thread Greg Wooledge
ID TTY TIME CMD 1152 pts/300:00:00 bash 542197 pts/300:00:00 sleep 542200 pts/300:00:00 ps unicorn:~$ ps -fp 542197 UID PIDPPID C STIME TTY TIME CMD greg 542197 1 0 08:59 pts/300:00:00 sleep 37 wait -n *does* appear to acknowledge

Re: incorrect cursor position when navigating with 'ALT-b'

2024-02-01 Thread Greg Wooledge
On Thu, Feb 01, 2024 at 01:55:50PM +0100, Korneel Dumon wrote: > Repeat-By: > Execute the following command: > > curl -X POST -H "Content-Type: application/json" > https://ec.europa.eu/taxation_customs/vies/rest-api/check-vat-test-service > -d '{"countryCode":"BE", "vatNumber":"00"}

Re: glob-expand-word and vi-command mode

2024-02-02 Thread Greg Wooledge
On Fri, Feb 02, 2024 at 03:39:54PM +0100, Mike Jonkmans wrote: > [ mkdir test; cd test; touch file1 file2 ] > > Going into `vi-command' mode on the line `ls *' puts the cursor on the `*'. > Then `glob-expand-word' does nothing with the `*', it just inserts a space. > Resulting in `ls *' (cursor s

Re: set-e and command expansion

2024-02-04 Thread Greg Wooledge
On Sun, Feb 04, 2024 at 08:27:56PM +0300, Van de Bugger wrote: > Case 3: echo $(false) > > $ cat ./test > #!/bin/bash > set -e > echo before > echo $(false) > echo after > > $ ./test > before > > after > > Oops, in this case the script is NOT terminated before "echo after", but > co

Re: printf - strange behaviour in debug mode (BASH_VERSION="5.2.21(1)-release")

2024-02-08 Thread Greg Wooledge
On Thu, Feb 08, 2024 at 05:48:18PM +0200, Timotei Campian wrote: > The culprit function is *printargs() { printf "%s|" "$@"; echo; }* > > calling it with no arguments it prints as expected the pipe: "|" > while in debug mode (set -x), only a *blank line* is printed: > > $ printargs > printargs >

Re: possible bash bug bringing job. to foreground

2024-02-17 Thread Greg Wooledge
On Sat, Feb 17, 2024 at 01:30:00PM +, John Larew wrote: > Repeat-By: 1: (sleep 15s; set -m; fg %%; exit ) & 2: (sleep 15s; set -m; fg > %+; exit ) &  You're using %% or %+ inside a shell where there have NOT been any background jobs created yet. The sleep 15s runs in the foreground, because

Re: possible bash bug bringing job. to foreground

2024-02-17 Thread Greg Wooledge
On Sat, Feb 17, 2024 at 07:41:43PM +, John Larew wrote: > After further examination, the examples with "fg $$" and "fg $!" clearly do > not bring the subshell into the foreground, as they are evaluated prior to > the subshells background execution. > I'm trying to bring the subshell to the fo

Re: Unable to close a file descriptor using exec command

2024-03-03 Thread Greg Wooledge
On Sun, Mar 03, 2024 at 10:29:17PM +, Venkat Raman via Bug reports for the GNU Bourne Again SHell wrote: > Repeat-By: > exec 2>&test1 commands freezes the terminal and unable to close the > fd. > > Fix: > [Is there a sane way to close the fd?] You're using the wrong syntax.

Re: "local -g" declaration references local var in enclosing scope

2024-03-10 Thread Greg Wooledge
On Sun, Mar 10, 2024 at 04:01:10PM -0400, Lawrence Velázquez wrote: > Basically, without an assignment, "local -g" does nothing. Well, the original purpose of -g was to create variables, especially associative arrays, at the global scope from inside a function. I think this thread has been asking

Re: "local -g" declaration references local var in enclosing scope

2024-03-10 Thread Greg Wooledge
On Sun, Mar 10, 2024 at 06:39:19PM -0400, Lawrence Velázquez wrote: > On Sun, Mar 10, 2024, at 5:36 PM, Greg Wooledge wrote: > > Here it is in action. "local -g" (or "declare -g") without an assignment > > in the same command definitely does things. > >

Re: multi-threaded compiling

2024-03-11 Thread Greg Wooledge
On Mon, Mar 11, 2024 at 06:51:54PM +0100, Mischa Baars wrote: > SECONDS=5; for (( i=0;i<32;i++ )); do { exit ${i}; } & pid[${i}]=${!}; done; > sleep ${SECONDS}; for (( i=0;i<32;i++ )); do wait -n ${pid[${i}]}; e=${?}; > echo "$(printf %3u ${i}) pid ${pid[${i}]} exit ${e}"; done; > /bin/bash: line

Re: multi-threaded compiling

2024-03-11 Thread Greg Wooledge
On Mon, Mar 11, 2024 at 07:22:39PM +0100, Mischa Baars wrote: > On Mon, Mar 11, 2024 at 6:22 PM alex xmb sw ratchev > wrote: > > > i also completly dont get ur issue > > > > f=( a.c b.c .. ) threads=$( nproc ) i=-1 r= > > > > while [[ -v f[++i] ]] ; do > > (( ++r > threads )) && > > wait -n >

Re: multi-threaded compiling

2024-03-11 Thread Greg Wooledge
> On Mon, Mar 11, 2024, 20:13 Mischa Baars > wrote: > > > Also I don't think that gives you an exit status for each 'exit $i' > > started. I need that exit status. "wait -n" without a PID won't help you, then. You don't get the PID or job ID that terminated, and you don't get the exit status.

Re: multi-threaded compiling

2024-03-11 Thread Greg Wooledge
On Mon, Mar 11, 2024 at 10:19:26PM +0100, Mischa Baars wrote: > On Mon, 11 Mar 2024, 21:08 Kerin Millar, wrote: > > The pid can be obtained with the -p option, as of 5.1. Below is a > > synthetic example of how it might be put into practice. I'd forgotten about that one. A recent addition, and o

Re: multi-threaded compiling

2024-03-12 Thread Greg Wooledge
On Tue, Mar 12, 2024 at 10:33:36AM +0100, Mischa Baars wrote: > bash -c 'set +m; seconds=1; for (( i=0;i<32;i++ )); do exit ${i} & done; > sleep ${seconds}; for (( i=0;i<32;i++ )); do wait -p pid; e=${?}; echo > "$(printf %3u ${i}) pid ${pid} exit ${e}"; done;' "wait -p pid" is not correct here.

Re: multi-threaded compiling

2024-03-12 Thread Greg Wooledge
On Tue, Mar 12, 2024 at 02:15:38PM +0700, Robert Elz wrote: > Date:Mon, 11 Mar 2024 17:25:57 -0400 > From:Chet Ramey > Message-ID: <322e10a6-3808-49be-aa9d-a1d367a90...@case.edu> > > | OK, here's the longer answer. When the shell is interactive, and job > | contro

Re: multi-threaded compiling

2024-03-12 Thread Greg Wooledge
On Tue, Mar 12, 2024 at 09:42:22AM +0100, Mischa Baars wrote: > Here's the script and the Makefile using "printf '<%s>'": Sadly, your mail user agent chose to attach "Makefile" with content-type application/octet-stream, which my MUA (mutt) refuses to show inline, or to include in a reply as quote

Re: nameref and referenced variable scope, setting other attributes (was "local -g" declaration references local var in enclosing scope)

2024-03-14 Thread Greg Wooledge
On Thu, Mar 14, 2024 at 08:27:33AM +0100, alex xmb sw ratchev wrote: > how to unset a nameref Look at "help unset". Specifically the -n option.

Re: nameref and referenced variable scope, setting other attributes (was "local -g" declaration references local var in enclosing scope)

2024-03-14 Thread Greg Wooledge
On Thu, Mar 14, 2024 at 08:29:47AM -0400, Zachary Santer wrote: > Alright, that's all fair. But this? > > On Sun, Mar 10, 2024 at 7:29 PM Zachary Santer wrote: > > > > Additionally, a nameref variable referencing a variable declared in a > > calling function hides that variable in the scope of t

Re: nameref and referenced variable scope, setting other attributes (was "local -g" declaration references local var in enclosing scope)

2024-03-14 Thread Greg Wooledge
On Thu, Mar 14, 2024 at 10:15:35AM -0400, Zachary Santer wrote: > > $ cat ./nameref-what > > #!/usr/bin/env bash > > > > func_1 () { > > local var_3='EGG' > > func_2 > > printf '%s\n' "func_1:" > > local -p var_3 > > } > > > > func_2 () { > > local -n nameref_3='var_3' > > nameref_3='so

Re: "${assoc[@]@k}" doesn't get expanded to separate words within compound assignment syntax

2024-03-20 Thread Greg Wooledge
On Wed, Mar 20, 2024 at 07:11:34AM -0400, Zachary Santer wrote: > On Wed, Mar 20, 2024 at 12:29 AM Lawrence Velázquez wrote: > > A couple of previous discussions: > > - https://lists.gnu.org/archive/html/bug-bash/2020-12/msg00066.html > > - https://lists.gnu.org/archive/html/bug-bash/2023-06/m

Re: "${assoc[@]@k}" doesn't get expanded to separate words within compound assignment syntax

2024-03-20 Thread Greg Wooledge
On Wed, Mar 20, 2024 at 12:53:07PM +0100, alex xmb sw ratchev wrote: > On Wed, Mar 20, 2024, 12:49 Greg Wooledge wrote: > > > On Wed, Mar 20, 2024 at 07:11:34AM -0400, Zachary Santer wrote: > > > On Wed, Mar 20, 2024 at 12:29 AM Lawrence Velázquez > > wrote: &

Re: ${var@A}; hypothetical, related parameter transformations

2024-03-20 Thread Greg Wooledge
On Wed, Mar 20, 2024 at 03:05:56PM -0400, Zachary Santer wrote: > I want a declare command, no matter what ${var@A} gives me. I have to > write a function for that: generate_declare_command (). That function > can work a couple of reasonable ways: This seems rather theoretical to me. If the assoc

Re: "${assoc[@]@k}" doesn't get expanded to separate words within compound assignment syntax

2024-03-22 Thread Greg Wooledge
On Fri, Mar 22, 2024 at 11:23:35AM -0400, Chet Ramey wrote: > This is what you can do with @K. > > https://lists.gnu.org/archive/html/bug-bash/2021-08/msg00119.html > > Word splitting doesn't happen on the rhs of an assignment statement, so you > use eval. The @K quoting is eval-safe. It would b

Re: "${assoc[@]@k}" doesn't get expanded to separate words within compound assignment syntax

2024-03-22 Thread Greg Wooledge
On Fri, Mar 22, 2024 at 02:09:23PM -0400, Lawrence Velázquez wrote: > On Fri, Mar 22, 2024, at 12:54 PM, Greg Wooledge wrote: > > Also, I don't see the lower-case k transformation in the man page. > > It's at the end of the list: > > https://git.savannah.gnu.org/c

Re: "${assoc[@]@k}" doesn't get expanded to separate words within compound assignment syntax

2024-03-24 Thread Greg Wooledge
On Sun, Mar 24, 2024 at 01:04:38PM -0400, Zachary Santer wrote: > On Fri, Mar 22, 2024 at 11:23 AM Chet Ramey wrote: > > > > This is what you can do with @K. > > > > https://lists.gnu.org/archive/html/bug-bash/2021-08/msg00119.html > > > > Word splitting doesn't happen on the rhs of an assignment

Re: "${assoc[@]@k}" doesn't get expanded to separate words within compound assignment syntax

2024-03-24 Thread Greg Wooledge
On Sun, Mar 24, 2024 at 07:46:46PM +0200, Oğuz wrote: > On Sunday, March 24, 2024, Zachary Santer wrote: > > > > Yeah, but what can you do with @k? > > > It helps when reconstructing an associative array as a JSON object in JQ > > $ declare -A a=([x]=1 [y]=2) > $ jq --args -n '[$ARGS.po

Re: "${assoc[@]@k}" doesn't get expanded to separate words within compound assignment syntax

2024-03-24 Thread Greg Wooledge
On Sun, Mar 24, 2024 at 03:54:10PM -0500, Dennis Williamson wrote: > The @K transform outputs key value pairs for indexed arrays as well as > associative arrays (you used the @k transform which does word splitting and > loses the k-v sequence). The @K (capital) transformation gives you quoted stri

Re: Docco

2024-03-27 Thread Greg Wooledge
On Wed, Mar 27, 2024 at 10:00:06AM +0100, Phi Debian wrote: > $ man bash > ... > CONDITIONAL EXPRESSIONS > ... > >-a file > True if file exists. >-e file > True if file exists. > ... > > 'May be' would be nice for newbies to precise which options are [

bug-bash@gnu.org

2024-03-29 Thread Greg Wooledge
On Fri, Mar 29, 2024 at 09:02:12PM +1100, Reuben wrote: > $ echo cat /dev/stderr > bug > $ bash bug 2>&- > cat /dev/stderr I don't understand what you were trying to do here. > calling bash script 2>&- on linux > seems to make /dev/stderr refer to script, > though &2 seems unaffected. > using 2>&

Re: Scope change in loops with "read" built-in

2024-04-02 Thread Greg Wooledge
On Tue, Apr 02, 2024 at 08:08:57PM +, Linde, Evan wrote: > In a loop constructed like `... | while read ...`, changes to > variables declared outside the loop only have a loop local > scope, unlike other "while" or "for" loops. https://mywiki.wooledge.org/BashFAQ/024

Re: Scope change in loops with "read" built-in

2024-04-05 Thread Greg Wooledge
On Thu, Apr 04, 2024 at 08:39:51PM -0400, Dale R. Worley wrote: > To circumvent that, I've sometimes done things like > > exec 3<( ... command to generate stuff ... ) > while read VAR <&3; do ... commands to process stuff ... ; done > exec 3<- Please note that the syntax for closing a

Re: Potential Bash Script Vulnerability

2024-04-07 Thread Greg Wooledge
On Mon, Apr 08, 2024 at 12:23:38AM +0300, ad...@osrc.rip wrote: > - Looks for list of PIDs started by the user, whether it's started in > terminal or command line, and saves them into $DotShProcessList > - Takes $DotShProcessList and filters out those that don't have root access. > Those that do

Re: Potential Bash Script Vulnerability

2024-04-08 Thread Greg Wooledge
On Mon, Apr 08, 2024 at 12:40:55PM +0700, Robert Elz wrote: > or perhaps better just: > > main() { ... } ; main "$@" You'd want to add an "exit" as well, to protect against new lines of code being appended to the script.

Re: Potential Bash Script Vulnerability

2024-04-08 Thread Greg Wooledge
On Mon, Apr 08, 2024 at 02:23:18PM +0300, ad...@osrc.rip wrote: > Btw wouldn't it be possible (and worth) temporarily revoking write access to > the user while it's being executed as root, and restoring original rights > after execution? I think that would be a huge overreach. It would also lead

Re: echo test >& "quote'test"

2024-04-09 Thread Greg Wooledge
On Tue, Apr 09, 2024 at 01:37:08AM +, squeaky wrote: > Bash Version: 5.2 Patch Level: 21 Release Status: release > > Description: > > Running > echo test >& "quote'test" > should create the file "quote'test", but it creates "quotetest" > instead. I can confir

Re: Bash bug with ints beyond 2147483646

2010-11-03 Thread Greg Wooledge
On Tue, Nov 02, 2010 at 03:48:49PM -0400, Pete Gregory wrote: > echo {2147483640..2147483647} > dies with a malloc error In bash 4.1.9 under HP-UX 10.20, it consumes all available CPU until I kill it with SIGKILL. (I suppose there's a chance it might eventually have died due to malloc errors or w

Re: 'test' builtin of bash returns wrong value for '! -a FILE' operation

2010-11-08 Thread Greg Wooledge
On Fri, Nov 05, 2010 at 04:24:23PM -0500, Jonathan Nieder wrote: > >>> Please try > >>> % bash -c 'test ! -a . && echo true' > >>> and compare with the result of > >>> % bash -c '/usr/bin/test ! -a . && echo true' imadev:~$ bash -c 'test ! -a . && echo true' true imadev:~$ bash -c '/usr/bin/te

Re: Commands executed with $($prog) do not run properly

2010-11-08 Thread Greg Wooledge
On Sat, Nov 06, 2010 at 03:09:08AM +0100, Hans-Georg Bork wrote: > $ prog='find /test -type d ! -wholename "/test"' > $ echo $prog > find /test -type d ! -wholename "/test" > $ echo "$($prog)" > /test > /test/c > /test/b > /test/d > /test/a > $ This is an error in your script, not in bash. You'r

Re: Commands executed with $($prog) do not run properly

2010-11-08 Thread Greg Wooledge
On Mon, Nov 08, 2010 at 03:26:10PM +0100, Hans-Georg Bork wrote: > if this is true, then please explain the differences between > $ find /test -type d ! -wholename "/test" > (/test not shown) > and > $ prog='find /test -type d ! -wholename "/test"' > $ echo $prog > find /tes

Re: 'test' builtin of bash returns wrong value for '! -a FILE' operation

2010-11-09 Thread Greg Wooledge
On Tue, Nov 09, 2010 at 08:29:15PM +0900, OZAKI Masanobu wrote: > Greg Wooledge wrote: > > (On my system, there is no -a unary operator in the test(1) man page, but > > the command apparently supports one, undocumented. Isn't this fun?) > > Neither on my system. I fo

Re: Ctrl- does nothing

2010-11-09 Thread Greg Wooledge
On Tue, Nov 09, 2010 at 04:38:21AM +0100, hum...@chorion.ath.cx wrote: > the terminal can C-l, I use it with Debian's default /bin/bash > (3.2.39(1)-release) > but as soon as I go to /usr/local/bin/bash (where bash4 is), it doesn't work > any more. It would be helpful to indicate which version o

Re: Bug report

2010-11-12 Thread Greg Wooledge
On Thu, Nov 11, 2010 at 03:45:08PM -0500, sworddrag...@aol.com wrote: > Description: > It is possible to make input with the keyboard before bash is fully > initialized. This problem is critical on password inputs like the linux login. Bash has nothing to do with accepting passwords durin

Re: Issue with Getopts

2010-11-15 Thread Greg Wooledge
On Mon, Nov 15, 2010 at 12:41:19PM +0530, Ajay Jain wrote: > I use 'getopts' in my shell script. If I run script normally, it works > fine. However, the moment I run the script in the current shell (ie . > ), it fails returning error. Basically it is not able to > parse the arguments. Any reason, w

Re: Pesky here-document warnings

2010-11-16 Thread Greg Wooledge
On Tue, Nov 16, 2010 at 01:13:48PM -0800, Mun wrote: > I often get the following e-mailed to my by my system with the subject > of "Output from your job ": In other words, an at(1) job. > sh: line 497: warning: here-document at line 494 delimited by end-of-file > (wanted ``(dd if=/dev/urandom co

Re: Pesky here-document warnings

2010-11-17 Thread Greg Wooledge
On Tue, Nov 16, 2010 at 03:13:13PM -0800, Mun wrote: > That's just it, I don't have any cron scripts that use here-documents. at jobs. > Most of my cron jobs are fairly trivial scripts less than 100 lines long. Not cron. (Unless RHEL's cron spits out emails that look like at's? I've never seen

Re: ionice bash pid in bash_profile Fails

2010-11-22 Thread Greg Wooledge
On Sun, Nov 21, 2010 at 04:08:33PM -0900, Roger wrote: > When logging in, the following fails if put in $HOME/.bash_profile: > > ionice -c 2 -n 0 -p `pidof bash` > > ... I'm guessing, because bash hasn't started yet? I very much doubt you want to use `pidof bash` here. That would pick up EVER

<    1   2   3   4   5   6   7   8   9   10   >