Re: find len of array w/name in another var...(bash 4.4.12)

2020-10-20 Thread Martin Schulte
an=ar1 > echo ${#!an[@]} > -bash: ${#!an[@]}: bad substitution > > This works but feels kludgy > > an=ar1 > eval echo \${#$an[@]} > 4 I'm not quite sure what exactly you intend, but if you use declare -n an=ar1 instead of an=ar1, then echo ${#an} ${an[3]} will work as I expect. Best regards Martin

Re: find len of array w/name in another var...(bash 4.4.12)

2020-10-20 Thread Martin Schulte
an=ar1 > echo ${#!an[@]} > -bash: ${#!an[@]}: bad substitution > > This works but feels kludgy > > an=ar1 > eval echo \${#$an[@]} > 4 I'm not quite sure what exactly you intend, but if you use declare -n an=ar1 instead of an=ar1, then echo ${#an} ${an[3]} will work as I expect. Best regards Martin

Re: echo $'\0' >a does not write the nul byte

2021-01-17 Thread Martin Schulte
bytes themselves. To be exact, this is already caused by a Unix Kernel - strings passed by the exex* system calls are null terminated, too. As it is the default in the C programming language. Thus you can't pass a null byte in an argument when invoking a program. Best regards Martin

Re: echo $'\0' >a does not write the nul byte

2021-01-17 Thread Martin Schulte
e.g. another incompatibility between the builtin and the external echo. Best regards Martin

PROMPT_COMMAND causing strange cursor behavior

2015-04-27 Thread Martin Sebor
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-redhat-linux-gnu' -DCONF_VENDOR='redhat' -DLOCALEDIR='/usr/share/locale

Re: PROMPT_COMMAND causing strange cursor behavior

2015-04-28 Thread Martin Sebor
On 04/28/2015 08:26 AM, Chet Ramey wrote: On 4/27/15 1:26 PM, Martin Sebor wrote: Bash Version: 4.3 Patch Level: 33 Release Status: release Description: When the PROMPT_COMMAND variable is set to a command such a printf it causes the cursor to jump to disappear or jump to the wrong positions

Re: implicit redirection of background within pipeline

2016-01-11 Thread Martin Kealey
Surely a pipe counts as an explicit redirection? And even if it didn't, the inconsistency between the first and subsequent asynchronous elements is confusing. On 12 Jan 2016 02:41, "Chet Ramey" wrote: > On 1/10/16 12:54 PM, Piotr Grzybowski wrote: > > hey, > > > > I am quite sure it happens her

Re: implicit redirection of background within pipeline

2016-01-12 Thread Martin Kealey
quot; but it fails to mention that this applies to pipes as well; so I submit that it is a reasonable interpretation that a pipe on an outer block counts as an (explicit) redirection for the purpose of reading the "Asynchronous Lists" sub section. What do other shells do? Ksh? Dash? Zsh? -Martin

Re: implicit redirection of background within pipeline

2016-01-13 Thread Martin Kealey
On 13 Jan 2016 8:14 p.m., "Andreas Schwab" wrote: > I don't think so. > http://pubs.opengroup.org/onlinepubs/9699919799/utilities/V3_chap02.html#tag_18_07 > doesn't mention pipelines. That was rather my point. Given that they aren't mentioned, one has to take them as read, otherwise even ( ( foo

Re: implicit redirection of background within pipeline

2016-01-13 Thread Martin Kealey
n its parts. But we have to assume it does, otherwise all manner of stuff is broken, even though they haven't written it. -Martin

Re: implicit redirection of background within pipeline

2016-01-13 Thread Martin Kealey
On Wed, 13 Jan 2016, Chet Ramey wrote: > On 1/13/16 4:08 AM, Andreas Schwab wrote: > > Martin Kealey writes: > > > >> What do other shells do? Ksh? Dash? Zsh? > > > > $ ksh -c 'printf "foo1\nfoo2\n" | { (read x; echo 1: $x) & (read x; echo

set command overrides my ARGV array

2016-12-27 Thread Martin MOKREJŠ
arg3 $ I am on Gentoo Linux: # emerge -pv app-shells/bash These are the packages that would be merged, in order: Calculating dependencies... done! [ebuild R] app-shells/bash-4.4_p5-r1::gentoo USE="net nls (readline) -afs -bashlogger -examples -mem-scramble -plugins" 0 KiB Thank you for comments, Martin

Re: set command overrides my ARGV array

2017-01-08 Thread Martin MOKREJŠ
Hi, I forgot to say thanks to all of you who responded. I think the manual page needs improvement. This is just confusing. Martin Eric Blake wrote: > On 12/27/2016 10:21 AM, Martin MOKREJŠ wrote: >> Hi, >> I wanted to enable error code reporting for piped processes. This >

shopt compat

2024-08-13 Thread Martin Kealey
ted to match any new available levels. What was the original purpose of this? Was it just to double-check that there weren't bugs in the rest of the shell_compatibility_level logic? If so, would it be acceptable to omit this check from my new version? -Martin PS: This patch is dependent on a

Manual entry for !!:$

2025-01-17 Thread Martin Schulte
l $ echo !!:$ echo /dev/null /dev/null 5.2 states (correctly from my point of view): _ ... Subsequently, expands to the last argument to the previous simple command executed in the foreground, after expansion. ... $ echo hello > /dev/null $ echo $_ hello Best regards, Martin

Re: ;exit in bash history causes bash to exit

2025-03-25 Thread Martin Schulte
iately close Is there maybe something broken in your setup? Best regards, Martin

Re: Tilde expansion in PATH in POSIX-Mode

2025-05-30 Thread Martin Schulte
is broken in bash 5.1 POSIX mode unless patch > 13 is applied: > https://lists.gnu.org/archive/html/bug-bash/2022-01/msg8.html Thanks for the explanation! Martin

Tilde expansion in PATH in POSIX-Mode

2025-05-30 Thread Martin Schulte
-c 'echo $BASH_VERSION; PATH=~/x:~/y; echo $PATH' 5.1.4(1)-release /home/schulte/x:~/y $ bash-5.2.37 --posix -c 'echo $BASH_VERSION; PATH=~/x:~/y; echo $PATH' 5.2.37(1)-release /home/schulte/x:/home/schulte/y Best regards, Martin

Re: UP does not invoke line history immediately

2022-05-20 Thread Martin D Kealey
;stty -a" and "bind -p" so that the current settings are recorded in the output log; then exit the shell to close the script session. As there are some significant caveats, please read "man script" (or https://man7.org/linux/man-pages/man1/script.1.html) before doing this

Re: Unfortunate error message for invalid executable

2022-05-29 Thread Martin D Kealey
rately whether the file exists. -Martin

Re: Revisiting Error handling (errexit)

2022-07-05 Thread Martin D Kealey
quot; works. In both cases the variable "x" is visible to (and modifiable by) everything that is called from "main"; so everything is inside the "main" function, "local" there is quite indistinguishable from true global. -Martin

Re: Revisiting Error handling (errexit)

2022-07-06 Thread Martin D Kealey
Modules can have conflicting requirements of global settings that require weird contortions to interoperate; so starting out by making this yet another global setting seems like a retrograde step. So I would like to propose an alternative approach. Firstly, I would reduce the action to simply "re

Re: Revisiting Error handling (errexit)

2022-07-08 Thread Martin D Kealey
setting is perpetuating the "wrong direction"; "local -" has the same dynamic scope as any other "local", which means magic action at a difference, and makes brittle code that can abort unexpectedly in production. -Martin

Re: $(( )): binary/unary VAR/NUM inconsistency

2022-07-08 Thread Martin D Kealey
empty is zero" behaviour as we get when writing "var" without a radix prefix. But my real point is that I shouldn't have to come here and make that point; rather, avoiding breaking changes, even "in the name of making scripts less buggy", should be the standing policy.

Re: Revisiting Error handling (errexit)

2022-07-12 Thread Martin D Kealey
extending from the current statement until the end of the inner-most enclosing compound statement, or the end of an explicit subshell, or the end of the file, or the end of the string that's being read by "eval"; whichever comes first. I'm in two minds whether this should be s

Re: Revisiting Error handling (errexit)

2022-07-12 Thread Martin D Kealey
tion back when it was added to the Bourne shell; the only saving grace then was that shell scripts were rarely longer than a page, so it didn't matter as much. I've just run a test in Bash v1.14.7 and (not unexpectedly) "set -e" had the same effect there. -Martin

Re: Arithmetic expression: interest in unsigned right shift?

2022-07-16 Thread Martin D Kealey
Hi Steffen, thanks for that. It will be especially useful for defining (( MAXINT = ~0 >>> 1 )). This reminds me of some other operations I've been meaning to implement, including true modulus +% (where the sign of the result always matches the divisor) with the corresponding flooring division +/

Re: Arithmetic expression: interest in unsigned right shift?

2022-07-16 Thread Martin D Kealey
Printf %u already reveals the word size, as do most kinds of overflow - albeit messily, like $((3**40)) At least by explicitly exposing the word size in a controlled manner, we can write code that avoids unintended overflow. -Martin On Sun, 17 Jul 2022, 11:54 Dale R. Worley, wrote: > Stef

Re: Arithmetic expression: interest in unsigned right shift?

2022-07-18 Thread Martin D Kealey
not being surprised by its behaviour. In my book that ranks such a shell as *more* complicated than one that does use floating point (or bignums). Case in point: just a few days ago we had a bug report from someone complaining that the exponentiation operator gave the wrong result, because they didn'

Re: functions can fully unset local vars in other scopes

2022-07-29 Thread Martin D Kealey
her to introduce new commands or options to get the new behaviours (*2). What consideration was given to creating “local --unset *VAR*” or “unset --local *VAR*” or some other equivalent that doesn't overload any existing command form? -Martin *1: To my mind, shopt compatNN is broken in a

Re: return exit code in EXIT trap

2022-08-05 Thread Martin D Kealey
h-4.4+ [i.e., behavior > (B)] is nothing wrong as it is effectively unspecified, but behavior (A) > seems still more reasonable to me. Behavior (B) is a source of problems > I concur with this assessment. -Martin

Re: cut loadable outputs extra newlines

2022-08-13 Thread Martin D Kealey
his is so that cut can be implemented as a small state machine using just getchar, putchar, and a counter. This avoids copying via a line buffer, and that implies there should be no line-length limit. So I'm a bit surprised that any kind of "getline" is used by the loadable version.

Re: Re: add custom environment variable in bash source code

2022-08-18 Thread Martin D Kealey
If you expect LD_PRELOAD to incorporate code into Bash itself, then you need to set it before you launch Bash; setting it once Bash is running is too late. What exactly is the LD_PRELOAD loading for you, and what does THAT do? On Thu, 18 Aug 2022, 09:19 , wrote: > Because I'm using Android, And

Looking to the future (was Re: Light weight support for JSON)

2022-08-28 Thread Martin D Kealey
low new scripts to be written without needing to constantly work around misfeatures that are 35 years past their use-by date. Which is it to be? -Martin PS: top of my list of most-hated misfeatures isn't any of the POSIX malapropisms, but rather the fact that we can't write "shopt comp

Re: Bash Coding style - Adopting C99 declarations

2022-08-28 Thread Martin D Kealey
ot;gcc -std=c23" will reject such code. Of course, compilers are unlikely to remove their compatibility modes any time soon, but I would hate to be stuck in a position of requiring "gcc -std=gnu23" to get both new *and* obsolete features at the same time. -Martin

Re: bug-bash Digest, Vol 238, Issue 2

2022-09-05 Thread Martin D Kealey
the literal text, so that when it later turns out that the variable is an assoc array, it can use that rather than the expression tree. This would of course suppress reporting expression syntax errors using bash -n. -Martin On Mon, 5 Sep 2022, 05:49 Yair Lenga, wrote: > Putting aside th

Supporting structured data (was: Re: bug-bash Digest, Vol 238, Issue 2)

2022-09-07 Thread Martin D Kealey
c indexing and slicing, so we don't have to resort to run-time lookup to figure out whether it should have been parsed as a numeric range expression (after we've already done so). And it leaves space in the syntax of dot-things to add operators we've haven't considered yet; perhaps

Re: Supporting structured data (was: Re: bug-bash Digest, Vol 238, Issue 2)

2022-09-11 Thread Martin D Kealey
On Wed, 7 Sept 2022 at 18:13, Yair Lenga wrote: > Thanks for providing feedback and expanding with new ideas. > > I believe the summary is: > > ${a.key1.key2} - Static fields > ${a.key1.$key2} - Mixed dynamic/static, simple substitution. > ${a.key1.{complex.$key2}} - For complex keys that may co

Re: Bash reference manual feedback

2022-09-12 Thread Martin D Kealey
be used in scripts. Of course this advisory has to actually show the characters that it's telling you to avoid. Or do you think it should also tell you to avoid: declare -a foo="(1 2)" declare -a foo=\(1\ 2\) -Martin

Re: self-reference to assoc.-array variable

2022-09-19 Thread Martin D Kealey
Regression appears to have occurred between bash-5.0.18 and bash-5.1-alpha at commit 712f80b0. (I note that this commit is missing from the master branch, which only includes bash-5.0.17 at commit.) I tried to find the change in the devel branch, but ugh, git diff between devel & master is unhelpf

Re: declare -F incorrect line number

2022-10-06 Thread Martin D Kealey
n name and source filename and line, though I can see the latter being somewhat tricky if it's created inside an eval. -Martin On Thu, 6 Oct 2022 at 08:29, Robert Elz wrote: > Date:Wed, 5 Oct 2022 15:36:55 -0400 > From:Chet Ramey > Message-ID: &l

Re: bash core dumps doing glob pattern on long string

2022-10-10 Thread Martin D Kealey
> > 1) [...] string should be limited to PATH_MAX [...] > 2) [...] have a fix recursion deep level [...] > 3) [...] Implement a stack deep check in the recursion [...] 4) compile globs into state machines, the same way that regexes get compiled, so that they can be matched without needing any recursion. -Martin

Re: declare -F incorrect line number

2022-10-10 Thread Martin D Kealey
s private settings and forming a closure to keep that access even after the outer function returns (never possible in Bash because dynamic scope doesn't work that way) 3. simply written one inside the other (possible as demonstrated by your own example above); 4. being hidden except when inside the outer function (always possible with unset -f or with the proposed function -L, never possible otherwise) -Martin

Re: bash core dumps doing glob pattern on long string

2022-10-11 Thread Martin D Kealey
d need a stack to be treated as magic match-never tokens. I say "extglob", but this would also speed up silly ordinary globs like [a-z]*[a-z]*[a-z]*[a-z]*[a-z]*[a-z]*[a-z]*[a-z]*[a-z]*[a-z]*[a-z]*[a-z]*[a-z] -Martin On Tue, 11 Oct 2022 at 15:57, Phi Debian wrote: > > > On Tue,

bash 5.2 bad substitution for ${x:+${x}[}

2022-10-20 Thread Martin von Gagern
Configuration Information [Automatically generated, do not change]: Machine: x86_64 OS: linux-gnu Compiler: gcc Compilation CFLAGS: -g -O2 uname output: Linux … 5.18.16-…-amd64 #1 SMP PREEMPT_DYNAMIC Debian 5.18.16-… (2022-…) x86_64 GNU/Linux Machine Type: x86_64-pc-linux-gnu Bash Version: 5.2 Pat

Re: bash "extglob" needs to upgrade at least like zsh "kshglob"

2022-10-28 Thread Martin D Kealey
This seems like a good reason to simply translate extglobs into regexes, which should run in linear time, rather than put effort into building and debugging a parallel implementation. -Martin PS: While we're about it, can we please fix the expansion of « a/*/b/c/d/* » so it only calls readd

Re: Subsequent Here Doc/String Never Evaluated in Process Substitution

2022-10-29 Thread Martin D Kealey
eem like a fairly serious issue if it's present in the 5.2.0 release. -Martin

Re: Multiline editing breaks if the previous output doesn't end in newline

2022-10-29 Thread Martin D Kealey
there is an increasing number of common new utilities that don't honour the POSIX requirements for a text stream, such as 'jq' in its "brief" mode; if you come across these, please file bug reports on them. If the maintainers push back, please point them at the POSIX standard. -Martin

Re: bash "extglob" needs to upgrade at least like zsh "kshglob"

2022-10-30 Thread Martin D Kealey
On Sat, 29 Oct 2022 at 22:15, Greg Wooledge wrote: > On Sat, Oct 29, 2022 at 04:50:00PM +1100, Martin D Kealey wrote: > > This seems like a good reason to simply translate extglobs into regexes, > > which should run in linear time, rather than put effort into building and

Re: bash "extglob" needs to upgrade at least like zsh "kshglob"

2022-10-30 Thread Martin D Kealey
the OS. The hard part is what to do with (!LIST), which was the point of my previous post. -Martin On Sun, 30 Oct 2022 at 23:35, Oğuz İsmail Uysal wrote: > On 10/30/22 3:25 PM, Martin D Kealey wrote: > > How much faster do you think it can be made? > I don't know, irrelevant though.

Re: string substitution broken since 5.2

2022-11-04 Thread Martin D Kealey
lease have an immediate point release turning this feature off by default, and then let's take another look at how this can be done without gratuitous breakage of existing code. -Martin PS: I'm puzzled why a bare '&' was chosen in the first place; that seems to provide

Re: [bash 4] 'test -v 1' is never true

2022-11-27 Thread Martin D Kealey
The expansion `$[var+replacement}` was part of the Bourne shell when I used it in 1985 (before POSIX was first published), whereas `test A -gt B` is rather newer, and `test -v` is only a Bash extension (and similarly wasn't added until later). The man and info pages have retained the rather terse

Re: declare XXX=$(false);echo $?

2022-12-02 Thread Martin D Kealey
ld be: ``` declare ARGS=$( getopt -o "$S_OPTS" -l "$L_OPTS" -n "$0" -- "$@" ) ERRORS=$? (( ERRORS == 0 )) || usage ``` or: ``` declare ARGS ERRORS=0 ARGS=$( getopt -o "$S_OPTS" -l "$L_OPTS" -n "$0" -- "$@" ) || usage ``` -Martin (PS: "Working" would be questionable, since putting `getopt` in a subshell prevents it from updating "$@"; and `test $? = 0` and its variants are pointless clutter.)

Re: BASH_XTRACEFD=1 read variable stdout flushing?

2023-01-18 Thread Martin D Kealey
BASH_XTRACEFD=1 to exec {BASH_XTRACEFD}>&1 -Martin

Re: 'exec -a' and $0 substitution

2023-01-26 Thread Martin D Kealey
whitespace 4. push these latter strings onto the front of argv 5. replace the exec path with a copy of (the new) argb[0] 6. re-start the execve procedure Failing to make the substitution in step 1 would leave the interpreter running but with no idea how to open the script so that it could run it. -Martin >

Re: SIGINT handling during async functions

2023-01-28 Thread Martin D Kealey
d an interactive shell in a tty without job control in the last 35 years. (*1) I contend that it's past time this POSIX misfeature was retired. In the meantime, « shopt -s background_without_magic » (*2) gets my vote, along with incorporating « nohup » as a built-in (so that Bash can guar

Re: unset does not remove functions like a[b] unless -f is specified

2023-02-01 Thread Martin D Kealey
than add more weirdness to the behaviour. -Martin

Re: SIGINT handling during async functions

2023-02-06 Thread Martin D Kealey
On Fri, 3 Feb 2023 at 07:17, Chet Ramey wrote: > On 1/28/23 5:56 AM, Martin D Kealey wrote: > > Firstly, let's just leave aside "POSIX requires this" for a bit. > Be that as it may, POSIX exists and this is a requirement. It's also how > other shells behave. &

Re: Regression in pattern substitution with compat42

2023-02-09 Thread Martin D Kealey
t;don't use after" date, so that script writers don't have to cope with broken versions potentially remaining forever? -Martin PS: the current "beta testing" arrangement seems to me to have too few participants by at least two orders of magnitude. We need to encourage &

Re: "builtin jobs" does not output to stdout.

2023-02-12 Thread Martin D Kealey
in subshells of a session shell that has job control enabled, even though they don't actually do job control themselves. Maybe there should be an 'M' in $- when job control is actually active (in the top level session shell). What do others think about this? - Martin

Re: Regression in pattern substitution with compat42

2023-02-14 Thread Martin D Kealey
mpilers prior to C99. I would like a planning discussion for general future directions, preferably taking Bash towards a regular language, with POSIX compliance and "old Bash" compliance as shims. If we're just going to accept breaking changes willy-nilly, we make a lie of that stability. If we're not going to compensate by making linguistic and structural improvements, then in my opinion the only honest thing to do is to shut down the entire project: Bash 5.1 should be the last ever release. -Martin

Re: Bash 5.2 breaks our Arch Linux devtools

2023-02-15 Thread Martin D Kealey
ctually need it turned on, and turning it off would break it. There's no good reason to turn off extglob if you're writing a new script, as it only affects the validity of some very weird corner cases. # Without extglob this is a function definition; # with extglob it's an empty gl

Re: Having an alias and a function with the same name leads to some sort of recursion

2023-02-17 Thread Martin D Kealey
ut any syntax element into an alias and the shell will parse it. > We can quibble about contextual details and whether "syntax element" distinguishes "reserved word" from other "word" lexical tokens, but otherwise that's adequate. -Martin PS: I also fudged thing

Re: Cmd history is not displaying correctly

2023-02-19 Thread Martin D Kealey
I suspect the history file is corrupt; truncating a file while another process has it open for writing can do strange things. On Sun, 19 Feb 2023, 23:05 Mr. Dick Steel, wrote: > WARNING: The following will REPLACE your > current .bash_history file! Take care. > > 1. Start you term

Re: Document that here strings don't support brace expansion.

2023-03-14 Thread Martin D Kealey
I suggest avoiding enumerating exclusions (including removing any existing ones), and adding an explanation that "expansions that can produce multiple words are excluded". On Wed, 15 Mar 2023, 15:52 Alex Bochannek, wrote: > Chet, > > Thank you for the thoughtful responses. My thoughts below got

Re: $SECONDS and timeout values use realtime `gettimeofday()`

2023-03-25 Thread Martin D Kealey
On Fri, 24 Mar 2023 at 10:42, William Kennington via Bug reports for the GNU Bourne Again SHell wrote: > It would be nice if $SECONDS was using `clock_gettime(CLOCK_MONOTONIC, > &val)` as it would usually make the most sense when you want to know the > time since the script started. Generally n

Re: [PATCH 3/4] Port unwind protection to C23

2023-03-26 Thread Martin D Kealey
aper than the alternatives, so I don't see any likelihood of this *becoming* a problem for Bash in the future. (For other projects, sure, but not for Bash.) All that said, I'm all for tidying up the code so that it can compile cleanly and run reliably. -Martin On Mon, 27 Mar 2023 at 09:50,

Re: [PATCH 3/4] Port unwind protection to C23

2023-03-27 Thread Martin D Kealey
d keeping function types clear is really important. -Martin

Re: Junk at the end on history

2023-04-05 Thread Martin D Kealey
Is there any chance that your history contains a raw escape sequence that trigger the terminal to report attributes using `CSI…c` as described in the first answer to https://stackoverflow.com/questions/29939026/what-is-the-ansi-escape-code-sequence-escc Using "tail" would limit the output to just

Re: history fails with - in string

2023-04-13 Thread Martin D Kealey
words at all; and then the "b" stands alone as the only text on the line. -Martin On Fri, 14 Apr 2023 at 04:38, James Cloos wrote: > with bash-5.0.3, !foo-b reports > b > bash: b: command not found > > even when foo-bar is in history. > > there is nothing in the histo

Fwd: EOF at PS2

2023-05-04 Thread Martin D Kealey
could observe a difference in behaviour with this change? (Maybe some crazy self-modifying script exists somewhere, but I can't imagine such a thing being particularly stable if it's relying on a *failure*. Would even a single person be negatively impacted by fixing this?

Re: `wait -n` returns 127 when it shouldn't

2023-05-17 Thread Martin D Kealey
ange. > ((code == 127)) && break > ((!code)) || status=$code > done > return $status > } > > # Eventually finishes: > while true; do ( > true & > false & > waitjobs > ) && break; done > I'm testing with Bash 5.1.4p47 -Martin

Re: `wait -n` returns 127 when it shouldn't

2023-05-17 Thread Martin D Kealey
ou care to speculate more precisely on where such silent reaping may occur, given the code as shown? -Martin PS: I'm not convinced that “trap ... SIGCHLD” needs to be in that list; it's the “wait” inside the trap that actually matters, and if you *don't* “wait” inside a SIGCHLD trap, things are going to get quite strange anyway.

Re: setarray[unsetkey] doesn't trigger nounset in arithmetic context

2023-05-21 Thread Martin D Kealey
ting. 2. ${#array[@]} gives the number of elements rather than the last index (minus 1). Being able to declare an array as non-sparse (so that all gaps "exist" with some default value) would fix this. -Martin

Re: setarray[unsetkey] doesn't trigger nounset in arithmetic context

2023-05-21 Thread Martin D Kealey
I was heading with my suggestion about non-sparse arrays. On Mon, 22 May 2023 at 07:01, Martin D Kealey wrote: [...] > 2. ${#array[@]} gives the number of elements rather than the last index > (minus 1). Being able to declare an array as non-sparse (so that all gaps > "exist" with some default value) would fix this. > -Martin

Re: setarray[unsetkey] doesn't trigger nounset in arithmetic context

2023-05-22 Thread Martin D Kealey
text. I think that cure would be worse than the disease, because it has undesirable hidden effects on operator precedence and order of evaluation. -Martin

array size vs index of last element (was Re: setarray[unsetkey] doesn't trigger nounset in arithmetic context)

2023-05-27 Thread Martin D Kealey
On Tue, 23 May 2023 at 23:32, Chet Ramey wrote: > On 5/22/23 10:56 PM, Martin D Kealey wrote: > > > For example, if one is filling an array in random order, rather than > > progressively adding to the end, then it is useful and makes sense to be > > able to ask the arr

bug-bash@gnu.org

2023-06-10 Thread Martin D Kealey
On Sun, 11 Jun 2023, 09:31 Grisha Levit, wrote: > The command printing code can fail to add a required semicolon when the > last word in the command ends with `&' > This could be obviated by unconditionally outputting a newline instead of a semicolon. I acknowledge that this style isn't to ever

Re: Command execution by creating file.

2023-06-20 Thread Martin D Kealey
of case is incomplete.) -Martin

Re: problem with continuation prompt on newlines with history back

2023-06-23 Thread Martin D Kealey
Hi Alex Is your history set to line mode or command mode? This changes whether recalling a multi-line history item gets put in the input buffer all at once or only one line of it, and that in turn changes whether you see PS2 in between the lines. On Sat, 24 Jun 2023, 03:34 alex xmb ratchev, wrot

Re: Enable compgen even when programmable completions are not available?

2023-06-26 Thread Martin D Kealey
shift ; done printf %s\\n "${@%%=*}" } eval "$( typeset -p )" ) ``` or ``` ( declare -a var_names=() function declare { local v for v do [[ $v = -* ]] || var_names+=("${v%%=*}") done } eval "$( typeset -p )" unset -f declare

Re: Enable compgen even when programmable completions are not available?

2023-06-26 Thread Martin D Kealey
n Mon, 26 Jun 2023 17:09:47 +1000 > Martin D Kealey wrote: > > > Hi Eli > > > > How about using the shell itself to parse the output of "typeset" (an > alias > > for "declare"), but redefining "declare" to do something different. This >

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

2023-06-29 Thread Martin D Kealey
refix, > 0xDIGITS, still allows just "0x" as a valid zero constant. > > Not sure whether this should be considered a bug, > and whether it's worth fixing - just letting you know. > No, definitely not. It's established behaviour, and should not be removed without an explicit shopt. -- -Martin

Re: maybe a bug in bash?

2023-06-29 Thread Martin D Kealey
t an ssh key only allows one particular command to be run. (Use multiple keys if you have multiple commands you want to run.) -Martin

Re: [PATCH 1/2] <<# indent-stripping heredoc

2023-07-14 Thread Martin D Kealey
On Fri, 14 Jul 2023 at 09:47, Grisha Levit wrote: > This patch implements the ksh93-style <<# redirection operator to enable > indentatable heredocs. On the whole I think this is great, and thankyou for working up the patch, but I would like to offer some comments and suggestions: Firstly, it'

Re: [PATCH 1/2] <<# indent-stripping heredoc

2023-07-18 Thread Martin D Kealey
esn't conflict with the other forms above. Then we can write: cat <<##| | line 1 indent 2 space |line 2 no indent (No EndMark is necessary; we simply stop when we reach a line that does not start with C.) -Martin

Re: slash appended to tab so its two // at end

2023-07-19 Thread Martin D Kealey
-F \([^ ]*\).*/\1/p' ) -Martin

Re: problem anomalies , possibly aliases related

2023-07-19 Thread Martin D Kealey
cture of the code, not the literal text. We expect it to exclude comments, extra blank lines, and names of aliases where they are used. Unless you actually need to modify how a script is PARSED, don't use aliases; use functions instead. -Martin PS: please use structure-indicative indentation when showing examples.

Re: problem anomalies , possibly aliases related

2023-07-20 Thread Martin D Kealey
rk-around is to enable alias expansion in scripts. *Grumble* -Martin PS: and people think I'm crazy for wanting to write new stuff in Perl, in preference to Bash. Bash as a language has nothing else going for it, so if after 28 years I still can't consider it stable, what is the point? >

Re: problem anomalies , possibly aliases related

2023-07-20 Thread Martin D Kealey
useful. (Non-local continue is a logical extension of that.) Saying that this *ought* to be done using aliases is not reasonable, as it means forgoing the other stuff that functions can do, like taking parameters, declaring local variables, or returning a status. -Martin

Re: problem anomalies , possibly aliases related

2023-07-21 Thread Martin D Kealey
On Fri, 21 Jul 2023, 04:09 Greg Wooledge, wrote: > On Fri, Jul 21, 2023 at 12:33:07AM +1000, Martin D Kealey wrote: > > Saying that this *ought* to be done using aliases is not reasonable, as > it > > means forgoing the other stuff that functions can do, like taking > &g

Re: comments inside command subst are handled inconsistently

2023-07-28 Thread Martin D Kealey
trying to "fix" this will have unintended consequences and likely break existing valid code. On the other hand, since everyone has now had 36+ years to update their scripts to get rid of backticks, maybe it's time to start issuing a warning when they're used at all? 🤪 -Martin >

Re: git amend commit with backticks on cli causes tty to crash

2023-07-30 Thread Martin D Kealey
ng for a quote mark or other closing token, meaning that it may still exit immediately despite that setting. (The number assigned to IGNOREEOF indicates how many times you have to type ctrl-D to cause the Shell to exit. Numbers in the range 3-15 can be useful) -Martin

Re: comments inside command subst are handled inconsistently

2023-07-30 Thread Martin D Kealey
On Sun, 30 Jul 2023, 08:22 Chet Ramey, wrote: > On 7/28/23 1:51 PM, Martin D Kealey wrote: > > > maybe it's time to start issuing a warning > > when [backticks are] used at all? 🤪 > > There's no reason to use `` over $(...), but that form is still a required

Re: ! history expansion occurs within arithmetic substitutions

2023-08-08 Thread Martin D Kealey
ould recommend turning on histreedit, so that it's less cumbersome to fix any unexpected history expansions. $ echo $(( ! 0 )) 1 $ Please don't go breaking existing functionality just because someone can't imagine a use for it. -Martin

Re: ! history expansion occurs within arithmetic substitutions

2023-08-11 Thread Martin D Kealey
with "The selected line…", to differentiate from the line just entered containing a "!". If you want to rearrange things, it should go immediately after describing phase 2. -Martin

Re: ! history expansion occurs within arithmetic substitutions

2023-08-15 Thread Martin D Kealey
On Tue, 15 Aug 2023 at 01:41, Chet Ramey wrote: > On 8/11/23 4:19 PM, Martin D Kealey wrote: > > I think it would be helpful to start this sentence with "The selected > > line…", to differentiate from the line just entered containing a "!". > > It

Re: Assignment to RO variable

2023-08-16 Thread Martin D Kealey
lem is that colon's own exit status is always zero, and that will prevent the exit status of the preceding command from propagating out of a case/esac block or out of a function. -Martin

Re: SLA Information

2023-08-18 Thread Martin D Kealey
the Shell language. Sadly most script writers have not even read Bash's own documentation, much less read and understood the POSIX standard. -Martin On Sat, 19 Aug 2023, 04:27 Malena Arduino via Bug reports for the GNU Bourne Again SHell, wrote: > To whom it may concern, > > I am wo

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

2023-08-21 Thread Martin D Kealey
could make things worse in corner cases, and could conceivably break scripts that rely on the current behaviour. -Martin >

<    1   2   3   4   >