Re: parameter expansion null check fails for arrays when [*] or [@] is used

2022-03-23 Thread Ilkka Virta
On Tue, Mar 22, 2022 at 11:52 PM L A Walsh wrote: > On 2022/03/21 05:45, Andreas Luik wrote: > > Description: > > Bash fails to correctly test for parameter to be unset or null > when the parameter is an array reference [*] or [@]. > > > > Repeat-By: > > > > myvar[0]= > > echo

Re: Interesting bug

2022-02-12 Thread Ilkka Virta
On Sat, Feb 12, 2022 at 8:25 PM David Hobach wrote: > I guess it closes the function and {echo is interpreted as string or so, > but that is probably not all (testCode is e.g. never executed). > Let's see if I get this right. Removing the irrelevant parts, your code is pretty much this:

Re: I've found a vulnerability in bash

2021-11-19 Thread Ilkka Virta
On Fri, Nov 19, 2021 at 12:53 PM Marshall Whittaker < marshallwhitta...@gmail.com> wrote: > You could argue that bash should parse filenames globbed from * that start > with - and exclude them specifically, > Or a shell could prepend ./ to all globs relative globs. Not sure if that would change

Re: I've found a vulnerability in bash

2021-11-17 Thread Ilkka Virta
On Wed, Nov 17, 2021 at 2:42 PM Marshall Whittaker < marshallwhitta...@gmail.com> wrote: > [marshall@jerkon]{04:09 AM}: [~/bashful] $ touch -- '--version' > [marshall@jerkon]{04:09 AM}: [~/bashful] $ rm * > rm (GNU coreutils) 8.30 > Copyright (C) 2018 Free Software Foundation, Inc. > License

Re: bash conditional expressions

2021-11-17 Thread Ilkka Virta
On Wed, Nov 17, 2021 at 1:33 PM Andreas Schwab wrote: > On Nov 17 2021, Michael J. Baars wrote: > > > When -N stands for NEW, and touch (-am) gives you a new file > > It doesn't. The file hasn't been modified after it was last read. > touch creates the given file if it doesn't previously

Re: bash conditional expressions

2021-11-15 Thread Ilkka Virta
On Mon, Nov 15, 2021 at 5:21 AM Greg Wooledge wrote: >relatime > Update inode access times relative to modify or change > time. > Access time is only updated if the previous access time was > ear‐ > lier than the current modify or change

Re: bash conditional expressions

2021-11-12 Thread Ilkka Virta
On Fri, Nov 12, 2021 at 3:22 PM Mischa Baars wrote: > It is how my makefiles work :) > Sounds to me you're not using Make, but some self-made tool, so the files you have would be more properly called build scripts or whatever, and not makefiles.

Re: Arbitrary command execution from test on a quoted string

2021-10-29 Thread Ilkka Virta
On Fri, Oct 29, 2021 at 1:01 AM elettrino via Bug reports for the GNU Bourne Again SHell wrote: > user@machine:~$ USER_INPUT='x[$(id>&2)]' > user@machine:~$ test -v "$USER_INPUT" > uid=1519(user) gid=1519(user) groups=1519(user),100(users) > What you're doing here, is having the user name a

Re: Misleading error when attempting to run foreign executable

2021-10-04 Thread Ilkka Virta
On Mon, Oct 4, 2021 at 4:46 PM Chet Ramey wrote: > Bash reports the error it gets back from execve. In this case, it's > probably that the loader specified for the executable isn't present on your > system. > OTOH, for a script, Bash checks to see if the problem is with the interpreter and

Re: Exclamation mark when using character classes

2021-08-21 Thread Ilkka Virta
What do you get with [![:digit:]] then? It seems to work the same with both ! and ^ here: $ now=$EPOCHREALTIME $ echo "${now%[^[:digit:]]*}" "${now#*[^[:digit:]]}" 1629544775 183030 $ echo "${now%[![:digit:]]*}" "${now#*[![:digit:]]}" 1629544775 183030 On Fri, Aug 20, 2021 at 10:30 PM

Re: EPOCHREALTIME

2021-08-19 Thread Ilkka Virta
On Thu, Aug 19, 2021 at 4:12 PM hancooper wrote: > On Thursday, August 19, 2021 12:58 PM, Léa Gris > wrote: > > (LC_NUMERIC=C; echo "$EPOCHREALTIME") > > the unix time stamp is merely the number of > seconds between a particular date and the epoch. Technically, it should > be pointed out >

@K transformation

2021-08-19 Thread Ilkka Virta
On Thu, Aug 19, 2021 at 5:49 AM Koichi Murase wrote: > FYI, zsh provides this feature for associative arrays with the syntax > ${(kv)assoc} or ${(@kv)assoc}. Note that Bash-5.1 already has a > similar feature ${array[@]@K}, but the substitution result is quoted > so cannot be directly used for

Re: bash-5.1.8 does not compile anymore on HP-UX due to invalid shell syntax

2021-08-17 Thread Ilkka Virta
On Tue, Aug 17, 2021 at 5:40 PM Greg Wooledge wrote: > I'm still wondering what issue the OP is actually seeing. If they claim > that changing ${GCC+-stuff} to ${GCC:+-stuff} in some file fixes things, > and if they also claim that *something* is setting the GCC variable to > the empty string

Re: RFE: new option affecting * expansion

2021-08-17 Thread Ilkka Virta
On Tue, Aug 17, 2021 at 5:36 AM Dale R. Worley wrote: >cat $( glob * ) > > where glob would get one argument, "*", and output a list of file > names. A glob-by-modification-date program would be a better solution > for this need, IMHO. > So that program would have to duplicate the globbing

Re: An alias named `done` breaks for loops

2021-08-16 Thread Ilkka Virta
On Sun, Aug 15, 2021 at 2:00 AM George Nachman wrote: > Defining an alias named `done` breaks parsing a for loop that does not have > an `in word` clause. > alias done="" > Works for me: $ set -- a b c $ alias done='echo hi; done' $ for x do done hi hi hi Not that I think it's a good idea to

Re: Word splitting for $@ in variable assignment

2021-06-25 Thread Ilkka Virta
On Thu, Jun 24, 2021 at 5:20 PM Chet Ramey wrote: > On 6/24/21 4:09 AM, Ilkka Virta wrote: > > > But 3.4 Shell Parameters is a bit confusing: "Word splitting is not > > performed, with the exception of "$@" as explained below." > > This means that

Re: Word splitting for $@ in variable assignment

2021-06-24 Thread Ilkka Virta
On Thu, Jun 24, 2021 at 10:53 AM Alvin Seville wrote: > Hello! I want to understand why the following code doesn't produce any > error: > set -- "a b" "c" > a="$@" > ? I expected smth like: main.sh: line 2: b: command not found due to word > splitting according to documentation > < >

Re: Prefer non-gender specific pronouns

2021-06-06 Thread Ilkka Virta
On Sun, Jun 6, 2021 at 2:49 PM Léa Gris wrote: > Either you're acting in bad faith, or you're so confused by your > gender-neutral delusion that you don't remember that in normal people's > grammar, "they" is a plural pronoun. > Argh, no, that's just an example of the fact that I can't read.

Re: !(.pattern) can match . and .. if dotglob is enabled

2021-06-06 Thread Ilkka Virta
On Sun, Jun 6, 2021 at 1:31 PM Ilkka Virta wrote: > Personally, I'd just want an option to always make . and .. hidden from > globs. Or rather, > to never generate . or .. as a pathname component via globbing. But > without affecting > other behaviour, like dotglob, and wit

Re: !(.pattern) can match . and .. if dotglob is enabled

2021-06-06 Thread Ilkka Virta
> Can you write a set of rules that encapsulates what you would like to see? > Or can the group? > I think it's a bit weird that !(.foo) can match . and .. when * doesn't. The other means roughly "anything here", and the other means "anything but .foo here", so having the latter match things the

Re: Prefer non-gender specific pronouns

2021-06-06 Thread Ilkka Virta
On Sun, Jun 6, 2021 at 5:50 AM Léa Gris wrote: > Le 05/06/2021 à 18:47, John Passaro écrivait : > > I can see a couple reasons why it would be a good thing, and in the con > > column only "I personally don't have time to go through the manual and > make > > these changes". but I'd happily upvote

Brace expansion ordering vs. parameter expansion

2021-04-29 Thread Ilkka Virta
On Thu, Apr 29, 2021 at 4:18 AM Chet Ramey wrote: > Maybe, but it's never worked that way and was never intended to. You can > get what you need using eval: > > eval echo \{1..${i}} > BTW, was there some background to why they're ordered like this? I'm not sure if I have heard the story, and

Re: Document variable names need to be all ASCII

2021-04-19 Thread Ilkka Virta
What a 'name' is, is further defined under "Definitions": "name: A word consisting solely of letters, numbers, and underscores, ..." But it seems you're right that it doesn't say the locale's idea of letters isn't taken into account. Some other shells do accept those. On Mon, Apr 19, 2021 at

Re: Changing the way bash expands associative array subscripts

2021-04-06 Thread Ilkka Virta
On Tue, Apr 6, 2021 at 6:53 PM Greg Wooledge wrote: > In that case, I have no qualms about proposing that unset 'a[@]' and > unset 'a[*]' be changed to remove only the array element whose key is > '@' or '*', respectively, and screw backward compatibility. > That also seems to be what Ksh and

Re: Changing the way bash expands associative array subscripts

2021-04-06 Thread Ilkka Virta
On Tue, Apr 6, 2021 at 6:13 PM Greg Wooledge wrote: > As a counter-proposal, Chet could entirely remove the special meaning > of unset 'a[@]' and introduce a new option to unset which would take > its place. It appears -a is not yet used, so that would be a good pick. > Unless I missed

Re: select syntax violates the POLA

2021-04-02 Thread Ilkka Virta
On Thu, Apr 1, 2021 at 7:59 PM Robert Elz wrote: > Alternatively > d=( $( ls -d /usr/src/pkg/*/$1 ) ) > or just > d=( $( printf %s\\n /usr/src/pkg/*/$1 ) ) > > Just to be sure.Personally I'd do > > set -- /usr/src/pkg/*/$1 > Just the glob is fine in the array

Re: select syntax violates the POLA

2021-04-02 Thread Ilkka Virta
On Fri, Apr 2, 2021 at 2:04 AM Robert Elz wrote: > chet.ra...@case.edu said: > | Yes, you need a list terminator so that `done' is recognized as a > reserved > | word here. `;' is sufficient. Select doesn't allow the `done' unless > it's > | in a command position. > > isn't really all that

Re: zsh style associative array assignment bug

2021-03-30 Thread Ilkka Virta
On Tue, Mar 30, 2021 at 1:40 AM Eric Cook wrote: > Its just when populating that array dynamically with another array > if that second array didn't contain `v1' hypothetically, the array gets > shifted to > > a=( [k1]=k2 [v2]=k3 [v3]= ) > which i would imagine to be unexpected for the author of

Re: zsh style associative array assignment bug

2021-03-29 Thread Ilkka Virta
On Mon, Mar 29, 2021 at 1:56 AM Greg Wooledge wrote: > Python is different: > > >>> y = ["a", "b", "c", "d"] > >>> dict(zip(y[::2], y[1::2])) > {'a': 'b', 'c': 'd'} > >>> x = ["a", "b", "c"] > >>> dict(zip(x[::2], x[1::2])) > {'a': 'b'} > > It seems to discard the last (unmatched) value. Also,

Re: zsh style associative array assignment bug

2021-03-28 Thread Ilkka Virta
On Sun, Mar 28, 2021 at 10:16 AM Oğuz wrote: > That an idea was borrowed from another shell doesn't mean it should be > implemented the same kludgy way. Besides, bash doesn't offer compatibility > with zsh. > You don't think the realm of POSIX-ish shells already has enough incompatibilities and

Re: Wanted: quoted param expansion that expands to nothing if no params

2021-03-24 Thread Ilkka Virta
On Wed, Mar 24, 2021 at 9:38 PM L A Walsh wrote: > Hmmm...Now that I try to show an example, I'm not getting > the same results. Grrr. Darn Heizenbugs. > Just remember that if you test with printf, it always prints at least once, which makes it look exactly as if it got an empty string

ignoreeof variable (lowercase) as a synonym for IGNOREEOF

2021-03-22 Thread Ilkka Virta
The lowercase 'ignoreeof' variable appears to act as a sort of a synonym to the uppercase 'IGNOREEOF'. Both seem to call into 'sv_ignoreeof', and the latter one set takes effect. I can't see the lowercase one documented anywhere, is this on purpose?

Re: is it a bug that \e's dont get escaped in declare -p output

2021-03-17 Thread Ilkka Virta
On Wed, Mar 17, 2021 at 8:26 PM Greg Wooledge wrote: > I thought, for a moment, that bash already used $'...' quoting for > newlines, but it turns out that's false. At least for declare -p. > It would be nice if it did, though. Newlines, carriage returns, escape > characters, etc. > It does

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

2021-01-17 Thread Ilkka Virta
On Mon, Jan 18, 2021 at 12:02 AM Martin Schulte wrote: > 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

Re: V+=1 doesn't work if V is a reference to an integer array element

2021-01-13 Thread Ilkka Virta
> > Lots of things "could be useful" if only they worked, but they don't work, > so you don't do them. > Yes, and it does work in 4.4. > The fact that this undocumented, unsupported hack "appeared to work" > with certain inputs in bash 4.4 is just an unfortunate event, unless > Chet decides to

Re: V+=1 doesn't work if V is a reference to an integer array element

2021-01-13 Thread Ilkka Virta
On Wed, Jan 13, 2021 at 7:49 PM Greg Wooledge wrote: > On Wed, Jan 13, 2021 at 07:00:42PM +0200, Oğuz wrote: > > $ declare -n b=a[0] > > I can't see any documentation that supports the idea that this should > be allowed in the first place. > It's arguably useful though, and works in 4.4

Re: Arithmetic pow results incorrect in arithmetic expansion.

2021-01-09 Thread Ilkka Virta
On Sat, Jan 9, 2021 at 9:14 AM Robert Elz wrote: > Not "all" other shells, most don't implement exponentiation at all, > since it isn't a standard C operator. > Which also means that the statement about the operators being "same as in the C language" doesn't really help figure out how this

Re: Arithmetic pow results incorrect in arithmetic expansion.

2021-01-09 Thread Ilkka Virta
On Sat, Jan 9, 2021 at 7:22 AM Oğuz wrote: > 9 Ocak 2021 Cumartesi tarihinde Hyunho Cho yazdı: > > $ echo $(( -2 ** 2 )) # only bash results in 4 > > 4 > `bc' does that too. Here's another trivial side effect of implementing > unary minus using binary minus: > Note that

Re: Associative array keys are not reusable in (( command

2021-01-08 Thread Ilkka Virta
On Fri, Jan 8, 2021 at 5:44 PM Chet Ramey wrote: > On 1/8/21 10:24 AM, Oğuz wrote: > > This situation is why bash-5.0 introduced the `assoc_expand_once' > option. > > But it allows arbitrary command injection. > > If you want to run array keys through word expansions, this is one > potential

Re: declare -p name=value thinks 'name=value' is variable

2021-01-08 Thread Ilkka Virta
On Fri, Jan 8, 2021 at 4:06 PM Chet Ramey wrote: > No. `declare -p' does not accept assignment statements. > The synopsis in the documentation doesn't make it clear, though. It shows only one case with -p and assignment, while the similar case of export -p is listed separately from the other

Re: Checking executability for asynchronous commands

2020-12-28 Thread Ilkka Virta
On Mon, Dec 28, 2020 at 3:16 PM Greg Wooledge wrote: > The problem is that the parent bash (the script) doesn't know, and > cannot know, that the command was stillborn. Only the child bash > process can know this, and by the time this information has become > available, the parent bash process

Re: while loops can not read "\"

2020-12-23 Thread Ilkka Virta
er or a newline." shouldn't make the text significantly heavier, given it already uses almost double the letters to spell out how the words are assigned to the names given in order. On Wed, Dec 23, 2020 at 4:44 PM Chet Ramey wrote: > On 12/22/20 9:13 AM, Ilkka Virta wrote: > > Arguab

Re: while loops can not read "\"

2020-12-22 Thread Ilkka Virta
Arguably it's a bug that 'help read' doesn't mention the effect of backslashes, other than what can be extrapolated from the description of -r. It only says "The line is split into fields _as with word splitting_", but word splitting doesn't recognize backslashes as special. It should not be

Re: increment & decrement error when variable is 0

2020-11-24 Thread Ilkka Virta
On Tue, Nov 24, 2020 at 12:07 AM Jetzer, Bill wrote: > ((--x)) || echo "err code $? on --x going > from $i to $x"; > > err code 1 on ++x going from -1 to 0 > That's not about --x, but of the ((...)) construct: "" (( expression )) The arithmetic expression is

Re: use of set -e inside parenthesis and conditionnal second command

2020-11-17 Thread Ilkka Virta
On Tue, Nov 17, 2020 at 4:07 PM Pierre Colombier via Bug reports for the GNU Bourne Again SHell wrote: > #2 > pierre@zebulon: ~ $ (set -e ; echo A ; false ; echo B ) && echo C.$? > #3 > pierre@zebulon: ~ $ bash -c 'set -e ; echo A ; false ; echo B ' && echo > C.$? If it's not a bug, I

Re: execve E2BIG (Argument list too long)

2020-09-30 Thread Ilkka Virta
On Wed, Sep 30, 2020 at 5:53 PM Michael Green wrote: > The included short script when run with the following command results > in execve "E2BIG (Argument list too long) errors". > > * The number of arguments can be tuned down to "seq 1 23694" and it > still occurs, but any lower and it

Re: Bash parameter expansion (remove largest trailing match, remove largest leading match, pattern replacement) does not work

2020-08-30 Thread Ilkka Virta
On Sat, Aug 29, 2020 at 11:13 PM Bruce Lilly wrote: > It's a bit more complicated than that; if, for example, some excerpt ended > up in regression tests, there would be a question about whether or not > there was a copyright violation. As I understand the GPL (IANAL), it > requires all parts

Re: Bash parameter expansion (remove largest trailing match, remove largest leading match, pattern replacement) does not work

2020-08-29 Thread Ilkka Virta
On Sat, Aug 29, 2020 at 9:56 PM Bruce Lilly wrote: > Please don't assume that something output by printf (without quoting) for > clarity is representative of actual expansion by the shell when properly > quoted. > If you don't want people to assume (and you shouldn't, if you want them to help

Re: Incrementing variable=0 with arithmetic expansion causes Return code = 1

2020-08-28 Thread Ilkka Virta
On Fri, Aug 28, 2020 at 4:04 PM Gabriel Winkler wrote: > # Causes error > test=0 > ((test++)) > echo $? > 1 > It's not an error, just a falsy exit code. An error would probably give a message. But to elaborate on the earlier answers, the value of the post-increment expression var++ is the _old_

Re: $(<...) fails with nested quoting.

2020-08-17 Thread Ilkka Virta
On Mon, Aug 17, 2020 at 3:53 PM Steven McBride wrote: > 'echo "$(<\"filename\")"' fails with No such file or directory > Quotes inside $() are independent from the ones outside. If you escape them, you get literal quotes as part of the filename. $ echo hello > '"filename"' $ echo

Re: Expand first before asking the question "Display all xxx possibilities?"

2020-08-06 Thread Ilkka Virta
On 6.8. 15:59, Chet Ramey wrote: On 8/6/20 8:13 AM, Ilkka Virta wrote: I think they meant the case where all the files matching the given beginning have a longer prefix in common. The shell expands that prefix to the command line after asking to show all possibilities. Only if you set

Re: Expand first before asking the question "Display all xxx possibilities?"

2020-08-06 Thread Ilkka Virta
common part anyway, and it might as well do it first, without asking. (Which just so happens to be what Zsh does...) -- Ilkka Virta / itvi...@iki.fi

Re: No word splitting for assignment-like expressions in compound assignment

2020-07-28 Thread Ilkka Virta
subscript on the LHS, but it didn't work as one. To be in line with a plain scalar assignment, the braces should probably not be expanded here. -- Ilkka Virta / itvi...@iki.fi

Re: Segfault in Bash

2020-07-14 Thread Ilkka Virta
ilable in the script itself. The message also seems to be much briefer for an interactive shell or a -c script. At least the latter ones might also benefit from the longer error message. -- Ilkka Virta / itvi...@iki.fi

Re: Segfault in Bash

2020-07-14 Thread Ilkka Virta
ho "$file" | grep -E "*.so$"); then continue; fi echo "library: $file" done Are you trying to find the .so files, or run them for some tests? Because it looks to me that you're running whatever that command substitution outputs, and not all dynamic libraries are made for that. -- Ilkka Virta / itvi...@iki.fi

Re: foo | tee /dev/stderr | bar # << thanks!

2020-07-06 Thread Ilkka Virta
of the various *BSD:s and Solaris, so even if not standard, it's not like it's Linux-only. -- Ilkka Virta / itvi...@iki.fi

Re: [PATCH 5.1] zread: read files in 4k chunks

2020-06-22 Thread Ilkka Virta
initially for testing. It always struck me as odd that Bash used such a small read of 128 bytes. Most of the GNU utils I've looked at on Debian use 8192, and a simple test program seems to indicate glibc's stdio reads 4096 bytes at one read() call. -- Ilkka Virta / itvi...@iki.fi

Re: Bug on bash shell - $PWD (and consequentely prompt) not updated while renaming current folder.

2020-06-20 Thread Ilkka Virta
f you need that often, I suppose you could run it from PROMPT_COMMAND: /tmp$ PROMPT_COMMAND='cd .' /tmp$ mkdir old /tmp$ cd old /tmp/old$ mv /tmp/old /tmp/new /tmp/new$ echo $PWD /tmp/new -- Ilkka Virta / itvi...@iki.fi

Could we have GLOBIGNORE ignore . and .. in subdirectories, too?

2020-05-28 Thread Ilkka Virta
a glob in the final part of the path, they should probably still be allowed, even if the word was otherwise a glob. (e.g. if something like foo/*/. happened to be useful in some case.) -- Ilkka Virta / itvi...@iki.fi

Re: Not missing, but very hard to see (was Re: Backslash missing in brace expansion)

2019-12-12 Thread Ilkka Virta
how printf %q outputs an empty string.  read -r -a a< <(printf "%q " {Z..a})  my -p a declare -a a=([0]="Z" [1]="\\[" [2]="''" [3]="\\]" [4]="\\^" [5]="_" [6]="\\\`" [7]="a") -- Ilkka Virta / itvi...@iki.fi

Re: Backslash missing in brace expansion

2019-12-06 Thread Ilkka Virta
s, so you can't do stuff like generating all the printable ASCII characters with it in Bash. -- Ilkka Virta / itvi...@iki.fi

Re: Feature Request: Custom delimeter for single quotes

2019-11-01 Thread Ilkka Virta
een the MAGIC_WORDs need not be escaped. Pardon my naïveté, does any such feature exist or are there good ways to accomplish this? If not, is this something that could feasibly be implemented? Would it be desirable? Thanks, Patrick -- Ilkka Virta / itvi...@iki.fi

Re: shebang-less script execution not resetting some options

2019-10-02 Thread Ilkka Virta
the various programs that allow forking off other programs, including find, xargs, many editors, etc. -- Ilkka Virta / itvi...@iki.fi

Re: Documentation Bug Concerning Regular Expressions?

2019-09-23 Thread Ilkka Virta
le of days, starting at this message from last Friday: https://lists.gnu.org/archive/html/bug-bash/2019-09/msg00042.html -- Ilkka Virta / itvi...@iki.fi

Re: Wrong command option in the manual examples

2019-09-23 Thread Ilkka Virta
be assumed to know the options supported by BSD utilities? -- Ilkka Virta / itvi...@iki.fi

Re: Incorrect example for `[[` command.

2019-09-21 Thread Ilkka Virta
On 21.9. 21:55, Dmitry Goncharov wrote: On Sat, Sep 21, 2019 at 12:34:39PM +0300, Ilkka Virta wrote: [[:space:]]*?(a)b isn't a well-defined POSIX ERE: 9.4.6 EREs Matching Multiple Characters The behavior of multiple adjacent duplication symbols ( '+', '*', '?', and intervals

Re: Incorrect example for `[[` command.

2019-09-21 Thread Ilkka Virta
:]]*?(a)b isn't a well-defined POSIX ERE: 9.4.6 EREs Matching Multiple Characters The behavior of multiple adjacent duplication symbols ( '+', '*', '?', and intervals) produces undefined results. https://pubs.opengroup.org/onlinepubs/9699919799.2018edition/basedefs/V1_chap09.html -- Ilkka

Re: Incorrect example for `[[` command.

2019-09-20 Thread Ilkka Virta
ld be used. I know the usual regex behavior is to find a match anywhere within the value, but since it's exactly the opposite of how regular pattern matches work, it's probably worth mentioning in some way. (Though I do think it's better to document things rather explicitly in general.) -- I

Re: Incorrect example for `[[` command.

2019-09-20 Thread Ilkka Virta
recognize the zero-width-matching parts don't affect what matches. (I suppose they would affect what goes to BASH_REMATCH[0], but the text doesn't mention that.) I think it would be a better example with the anchored version also presented for comparison. -- Ilkka Virta / itvi...@iki.fi

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

2019-07-29 Thread Ilkka Virta
starting a new process (as far as I know). An example that would actually run and demonstrate the issue might make it easier to see what's actually going on. -- Ilkka Virta / itvi...@iki.fi

Re: expression evaluation problem

2019-07-25 Thread Ilkka Virta
that the shell in general is rather slow, and almost any other language would be better if that is of concern. (awk, Perl, what have you.) -- Ilkka Virta / itvi...@iki.fi

Re: Combination of "eval set -- ..." and $() command substitution is slow

2019-07-16 Thread Ilkka Virta
ouldn't find one where the result was different. Did I miss something? -- Ilkka Virta / itvi...@iki.fi

Re: Arithmetic evaluation of negative numbers with base prefix

2019-06-18 Thread Ilkka Virta
+20120801-3.4 amd64Real, AT version of the Korn shell wooledg:~$ ksh -c 'echo ${.sh.version}' Version AJM 93u+ 2012-08-01 Seems kinda weird to continue calling it "ksh93" if it's being changed, but I don't make the decisions. -- Ilkka Virta / itvi...@iki.fi

Re: Arithmetic evaluation of negative numbers with base prefix

2019-06-17 Thread Ilkka Virta
)) # -80 echo $(( 10 * 10#1+23 )) #10*1 + 23 = 33 echo $(( 10# )) # error $ ./bash test.sh -1230 -80 33 test.sh: line 5: 10#: no digits in number (error token is "10#") $ ksh test.sh -1230 -80 33 0 -- Ilkka Virta / itvi...@iki.fi --- expr.c

Re: Arithmetic evaluation of negative numbers with base prefix

2019-06-14 Thread Ilkka Virta
seems to work in this case because 10# is treated as a constant number by itself (with a value of 0), and then the 1 is subtracted. try also e.g.: $ echo $((10#)) 0 echo $((0-10#-1)) # -1 UNEXPECTED. Would expect 1. So this is 0-0-1 = -1 -- Ilkka Virta / itvi...@iki.fi

Re: Code Execution in Mathematical Context

2019-06-06 Thread Ilkka Virta
(( 'a[i]++' )) Thu Jun 6 16:46:31 EEST 2019 So if we want "valid" values in the index to work, and invalid ones to not do anything nasty, I can't seem to find a case where quotes would help with that. -- Ilkka Virta / itvi...@iki.fi

Re: Code Execution in Mathematical Context

2019-06-05 Thread Ilkka Virta
On 5.6. 17:05, Chet Ramey wrote: On 6/4/19 3:26 PM, Ilkka Virta wrote: If the bad user supplied variable contains array indexing in itself, e.g. bad='none[$(date >&2)]' then using it in an arithmetic expansion still executes the 'date', single quotes or not (the array doesn't need t

Re: Code Execution in Mathematical Context

2019-06-04 Thread Ilkka Virta
ry to sanity-check any user-provided values first: $ case $var in *[^0123456789]*) echo "Invalid input" >&2; exit 1;; esac $ (( a[var]++ )) # safe now? -- Ilkka Virta / itvi...@iki.fi

Re: Arithmetic expansion with increments and output redirection

2019-04-24 Thread Ilkka Virta
" : "$(( i += 1 ))" Some find that easier to read, too: the increment isn't "hidden" within the other stuff on the command line. -- Ilkka Virta / itvi...@iki.fi

Re: bug: illegal function name?

2019-01-20 Thread Ilkka Virta
bug still. On 20.01.2019 18:18, Andreas Schwab wrote: On Jan 20 2019, Andrey Butirsky wrote: |$ unset 1a || ||bash: unset: `1a': not a valid identifier Use `unset -f'. Andreas. -- Ilkka Virta / itvi...@iki.fi

Re: Difference of extglob between 5.0.0(1)-release and 4.4.23(1)-release

2019-01-13 Thread Ilkka Virta
$ touch .foo aa.foo; bash -O extglob -c 'echo ?(aa).foo' aa.foo .foo The change in Bash 5.0 also makes @(aa|) different from ?(aa) , even though the distinction between those two doesn't appear immediately obvious. -- Ilkka Virta / itvi...@iki.fi

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

2018-11-13 Thread Ilkka Virta
sh isn't Bash by default on Debian and Ubuntu, so it might be you're just not running the script with Bash. -- Ilkka Virta / itvi...@iki.fi

Re: GNUbash v. 4.4.23-5 – Bash identifier location is non-correct in terminal

2018-10-29 Thread Ilkka Virta
%\n\e[0m'; } PROMPT_COMMAND=prompt_to_bol (I stole the main parts from the answers in https://unix.stackexchange.com/q/88296/170373 ) -- Ilkka Virta / itvi...@iki.fi

Re: Strange (wrong?) behaviour of "test ! -a file"

2018-10-21 Thread Ilkka Virta
xpressions" too? Perhaps also explicitly noting the clash with the binary operators in the descriptions of -a and -o, too. Something along the lines of the attached patch. I also think the description of the 3-argument test would be clearer with numbering, so I added that too. -- Ilkka Vi

Re: comment on RFE: 'shift'' [N] ARRAYNAME

2018-09-27 Thread Ilkka Virta
d) ashift somearray 2 -- Ilkka Virta / itvi...@iki.fi

Re: bash sockets: printf \x0a does TCP fragmentation

2018-09-22 Thread Ilkka Virta
1, "foo\n", 4)= 4 write(1, "bar\n", 4) = 4 +++ exited with 0 +++ -- Ilkka Virta / itvi...@iki.fi

Re: bash sockets: printf \x0a does TCP fragmentation

2018-09-22 Thread Ilkka Virta
. -- Ilkka Virta / itvi...@iki.fi

Re: Add sleep builtin

2018-08-22 Thread Ilkka Virta
lt builtin sleep is implemented. Just for those systems that happen to have both GNU Bash and GNU coreutils installed. -- Ilkka Virta / itvi...@iki.fi

Re: Add sleep builtin

2018-08-21 Thread Ilkka Virta
On 21.8. 14:34, konsolebox wrote: Also it's basically people's fault for not reading documentation. One should be aware enough if they enable the builtin. Yes, if it's not enabled by default. -- Ilkka Virta / itvi...@iki.fi

Re: Add sleep builtin

2018-08-21 Thread Ilkka Virta
for 90 seconds). I didn't see support for those in konsolebox's patch, so while that's not conflicting syntax per se, the lack of that option might trip someone. -- Ilkka Virta / itvi...@iki.fi

Re: Rational Range Interpretation for bash-5.0?

2018-08-15 Thread Ilkka Virta
considering special-casing just those three, I'd suggest adding a-f and A-F too, for patterns matching hex digits. So yeah, +1 from me. -- Ilkka Virta / itvi...@iki.fi

Re: Assignment of $* to a var removes spaces on unset IFS.

2018-08-15 Thread Ilkka Virta
be used. How IFS affects word splitting isn't just about $* , the issue is the same even if you only have one glob in a regular variable. -- Ilkka Virta / itvi...@iki.fi

Re: Tilde expansion in assignment-like context

2018-08-06 Thread Ilkka Virta
/bash-install' isn't an assignment, just a regular command line argument. The paragraph about assignments could be expanded to say "This applies also to regular command-line arguments that look like assignments." or something like that. -- Ilkka Virta / itvi...@iki.fi

Re: Unquoted array slice ${a[@]:0} expands to just one word if IFS doesn't have a space

2018-08-01 Thread Ilkka Virta
On 1.8. 15:12, Greg Wooledge wrote: On Wed, Aug 01, 2018 at 02:43:27PM +0300, Ilkka Virta wrote: On both Bash 4.4.12(1)-release and 5.0.0(1)-alpha, a subarray slice like ${a[@]:0} expands to just one word if unquoted (and if IFS doesn't contain a space): This just reinforces the point

Unquoted array slice ${a[@]:0} expands to just one word if IFS doesn't have a space

2018-08-01 Thread Ilkka Virta
is multiple words as expected with both [@] and [*]. An expansion like that should in most cases be quoted, but the current behaviour still seems a bit inconsistent. -- Ilkka Virta / itvi...@iki.fi

Re: Empty ""s in ARG in ${x:+ARG} expand to no words instead of the empty word if prepended/appended with space

2018-07-21 Thread Ilkka Virta
ot;<%s> " "$0" ${cond:+ "$value" }; echo;' ; done <> <> <> Or with multiple words inside: $ for shell in bash dash ksh "zsh -y" ; do $shell -c 'cond=1; printf "<%s> " "$0" ${cond:+"" "x" ""}; echo;' ; done <> <> <> <> <> It doesn't seem like a very good idea to rely on this, arrays would of course work better. Bash: GNU bash, version 4.4.12(1)-release (x86_64-pc-linux-gnu) ksh:version sh (AT Research) 93u+ 2012-08-01 zsh: zsh 5.3.1 (x86_64-debian-linux-gnu) dash: Debian's 0.5.8-2.4 -- Ilkka Virta / itvi...@iki.fi

Re: Number with sign is read as octal despite a leading 10#

2018-07-10 Thread Ilkka Virta
On 10.7. 18:09, Chet Ramey wrote: On 7/10/18 6:44 AM, Ilkka Virta wrote: I think the problematic case here is when the number comes as input from some program, which might or might not print a leading sign or leading zeroes, but when we know that the number is, in any case, decimal. E.g. 'date

Re: Word boundary anchors \< and \> not parsed correctly on the right side of =~

2018-07-10 Thread Ilkka Virta
se here. If you thought they meant "word boundary" or something, you're in the wrong language. -- Ilkka Virta / itvi...@iki.fi

Re: Number with sign is read as octal despite a leading 10#

2018-07-10 Thread Ilkka Virta
uot; $((a + 1)); done; echo' \ sh +159 +0159 -159 -0159 160 160 -158 -158 $ ksh --version version sh (AT Research) 93u+ 2012-08-01 $ zsh --version zsh 5.3.1 (x86_64-debian-linux-gnu) On 10.7. 13:44, Ilkka Virta wrote: I think the problematic case here is when the number comes as input

Re: Number with sign is read as octal despite a leading 10#

2018-07-10 Thread Ilkka Virta
est case, Worst case, and Just in case -- Ilkka Virta / itvi...@iki.fi

  1   2   >