Re: declare a="$b" if $a previously set as array

2014-12-09 Thread Greg Wooledge
On Tue, Dec 09, 2014 at 08:55:02PM +0800, konsolebox wrote: > > declare -g "$var=$something" > > It actually should be completely avoided. eval is the right tool for > that job (besides a variable declared with -n in 4.3+). Unfortunately, "declare -n" is the same as eval. We've had this discuss

Re: Documentation Update

2014-12-12 Thread Greg Wooledge
On Fri, Dec 12, 2014 at 09:59:50AM -0500, David J. Haines wrote: > When started interactively, bash sets the extglob shopt; however, that > fact seems to have been overlooked in the manpage. This is a compile-time setting. Your vendor probably turned this on. imadev:~$ bash-4.3 imadev:~$ shopt |

Re: unfinished command executed when TTY is closed

2014-12-17 Thread Greg Wooledge
On Wed, Dec 17, 2014 at 03:16:53PM -0500, Steve Simmons wrote: > Advance apologies if I'm misunderstanding, but the described bug looks like > reasonable behavior to me. It would be more reasonable for bash (or ssh, I'm not sure at what level this handling should occur) to discard the partially t

Re: Re: bug with German umlauts

2014-12-18 Thread Greg Wooledge
On Thu, Dec 18, 2014 at 04:18:29PM +0100, Lars-Daniel Weber wrote: (some HTML) Stop writing HTML-only email. At least include a textual version of the message. At best, ONLY include the textual version and not the HTML version. The issue was fixed in Bash 4.3. The datestamps on the patches for

Re: tab completion sort by modification time

2014-12-26 Thread Greg Wooledge
On Thu, Dec 25, 2014 at 12:34:08AM -0500, kamaraju kusumanchi wrote: > I would like to request a new feature in bash. > > When doing a tab completion inside a directory, I would like the files > to be listed in the order of modification time (similar to ls -rt). I think there would be a larger ge

Re: local assigned from command substitution disobeys set -eu

2014-12-30 Thread Greg Wooledge
On Tue, Dec 30, 2014 at 02:03:01PM +0200, Ville Oikarinen wrote: > I often use "set -eu" to make my scripts more robust by exiting when > there are errors. http://mywiki.wooledge.org/BashFAQ/105 > But one of my scripts just kept on running after failures. I found out > that the keyword "local" do

Re: undo local variable with unset

2015-01-05 Thread Greg Wooledge
On Mon, Jan 05, 2015 at 01:14:53PM -0700, Poor Yorick wrote: > It's nice to be able to create a function like unlocal that moves > local > variables out of the way, but I'm wondering if it can be relied on in > future > versions: Chet can give the authoritative answer about future directions, bu

Re: for ((i=0; i<3 && i!=1; i++))

2015-01-12 Thread Greg Wooledge
On Mon, Jan 12, 2015 at 05:26:15PM +0800, l_j_f wrote: > for ((idx=0; idx<3 && idx != current; idx++)); do > echo $idx > done > # I think it should be > 0 > 2 No, this is not a bug. The second expression in "for ((expr; expr; expr))" tells bash when to terminate

Re: Tilde expansion differences between 4.3 and 4.2

2015-01-14 Thread Greg Wooledge
On Wed, Jan 14, 2015 at 03:09:47PM +0100, Ondrej Oprala wrote: > echo "${PWD/#$HOME/~}" > > Result of echo in 4.3: > /home//MYDIR imadev:~/tmp$ echo "$BASH_VERSION -- ${PWD/#$HOME/\~}" 4.3.30(5)-release -- ~/tmp imadev:~/tmp$ bash-4.2 -c 'echo "$BASH_VERSION -- ${PWD/#$HOME/\~}"' 4.2.46(1)-relea

Re: Empty strings disappear from array splice

2015-01-20 Thread Greg Wooledge
On Mon, Jan 19, 2015 at 03:22:36PM -0800, marc.coiff...@gmail.com wrote: > Here is the minimal code sample to reproduce the bug (present in version 4.2, > corrected in 4.3 as far as I can tell) : > > arr1=( "" "" ) > arr2=( "${arr1[@]:1}" ) Seems to be either a Debian-specific bug, or a bug

Re: Empty strings disappear from array splice

2015-01-20 Thread Greg Wooledge
On Tue, Jan 20, 2015 at 01:39:02PM -0800, marc.coiff...@gmail.com wrote: > If you have time for a followup question, do you know who I should contact to > get these patches pushed to Debian ? I am writing a completion helper library > (based on parser combinators) and it needs this feature to funct

Re: which paradigms does bash support

2015-01-26 Thread Greg Wooledge
On Sun, Jan 25, 2015 at 08:11:41PM -0800, garegi...@gmail.com wrote: > As a programming language which paradigms does bash support. Declarative, > procedural, imperative? This belongs on help-b...@gnu.org so I'm Cc'ing that address. Shell scripts are procedural. The control structures are while

Re: How to monitor bash variables periodically

2015-01-26 Thread Greg Wooledge
On Mon, Jan 26, 2015 at 04:29:04PM +0100, Michael Mehari wrote: > What i meant by > variable monitoring is to periodically read variable values and store it > to a file for later processing. > The first approach i looked was to export this variable into the child > process and periodically stor

Re: [rvskmbr...@gmail.com: Re: Type-in programs using BASH]

2015-01-26 Thread Greg Wooledge
On Mon, Jan 26, 2015 at 10:14:19AM -0800, Ryan Cunningham wrote: > Sorry, I forgot to state that it could also be saved by an object code editor > and loaded then like you would load any other program in object code. Bash doesn't run object code, except in one very unusual situation: a user-suppl

Re: [rvskmbr...@gmail.com: Re: Type-in programs using BASH]

2015-01-26 Thread Greg Wooledge
On Mon, Jan 26, 2015 at 10:36:37AM -0800, Ryan Cunningham wrote: > I mean that the program would be loaded in the same manner in which Bash > would execute any other object-code program that isn't loaded /into/ Bash as > a builtin, like "ls", "su", and "dirname", all from GNU Coreutils. Bash doe

Re: [rvskmbr...@gmail.com: Re: Type-in programs using BASH]

2015-01-26 Thread Greg Wooledge
On Mon, Jan 26, 2015 at 01:32:21PM -0800, Ryan Cunningham wrote: > When you receive a program in *object code* form, you would type it into an > object code editor and then save it in a binary file. Why? Is it 1982 again? Are we typing in 6502 machine code from a glossy magazine? In the 21st ce

Re: [rvskmbr...@gmail.com: Re: Type-in programs using BASH]

2015-01-27 Thread Greg Wooledge
On Mon, Jan 26, 2015 at 04:12:45PM -0800, Ryan Cunningham wrote: > One day we'll be able to type in programs like these that are encoded in > machine code. But that day is not now. That day was the early 1980s. There WERE machine-code programs (small games) in glossy magazines that you could type

Re: If $HISTFILE is set to /dev/null and you execute more commands than $HISTFILESIZE, /dev/null is deleted.

2015-01-30 Thread Greg Wooledge
On Fri, Jan 30, 2015 at 09:58:43AM -0500, Chet Ramey wrote: > On 1/30/15 4:36 AM, crocket wrote: > > It turns out that tramp on emacs 24.4 sets $HISTFILE to /dev/null and > > makes bash delete /dev/null when I kill emacs. > > > > When /dev/null is not a character device but a regular file, a lot o

Re: [contrib]: setpgrp + killpg builtins

2015-02-03 Thread Greg Wooledge
On Sun, Feb 01, 2015 at 01:13:06AM +, Jason Vas Dias wrote: > 1. An "invoker.sh" process runs a "job.sh" bash script in a separate >process which runs a long-running (or non-terminating!) >'Simple Command' (not a shell "Job") (call it "nterm.sh"). > > 2. After a while, the originator d

Re: Unsetting all elements of an associative array

2015-02-04 Thread Greg Wooledge
On Wed, Feb 04, 2015 at 09:12:12AM +0100, isabella parakiss wrote: > I'm trying to use unset array[@] to empty an associative array, but something > goes wrong. What caused you to believe that would work? > This produces an error: > $ declare -A array; unset array[@]; array[path/directory]=value

Re: Unsetting all elements of an associative array

2015-02-04 Thread Greg Wooledge
On Wed, Feb 04, 2015 at 03:37:07PM +0100, Piotr Grzybowski wrote: > On Wed, Feb 4, 2015 at 2:39 PM, Greg Wooledge wrote: > > > On that note, today I learned that you are not allowed to use either * > > or @ as the index of an associative array in bash. I guess I can see why,

Re: Does [ -f FILE ] have a bug on testing a symlink ?

2015-02-09 Thread Greg Wooledge
On Mon, Feb 09, 2015 at 09:00:12PM +, Cheng Rk wrote: > -f FILETrue if file exists and is a regular file. > > but why it returned true on a symlink to a regular file? > > $ [ -f tmp/sym-link ] && echo true > true It's supposed to work this way. -f resolves symlinks and tests the tar

Re: process substitution stdout connected to pipeline

2015-02-13 Thread Greg Wooledge
On Fri, Feb 13, 2015 at 05:10:42PM +, Pádraig Brady wrote: > bash though seems to connect the stdout of the process substitution > to the pipeline, which seems like a bug: > $ : | tee >(md5sum) | sha1sum > 253a7a49edee354f35b2e416554127cf29c85724 - md5sum inherits the anonymous pipe to sha1su

Re: array subscripts act differently for integers(ie. let)

2015-02-16 Thread Greg Wooledge
On Mon, Feb 16, 2015 at 03:04:49AM +0100, emanuelczi...@cryptolab.net wrote: > please see attached bash script to reproduce because that explains > it much better than I could in words. The argument you give to let should be quoted. imadev:~$ declare -A ar imadev:~$ idbad1="bad strin

Re: bang-hash behavior change?

2015-02-26 Thread Greg Wooledge
On Wed, Feb 25, 2015 at 07:40:07PM -0500, Milo H. Fields wrote: > echo " parens: ${!#}" > bash 4.1.17: > > $ sh jnk arg1 arg2 > > plain: !# > > parents: arg2 Can't say I've ever seen this syntax before. It looks like you are trying to get the last argument. The syntax I've seen for getting

Re: certain strings both legal and illegal as associative array keys

2015-03-02 Thread Greg Wooledge
On Sun, Mar 01, 2015 at 12:05:53AM -0600, vampyre...@gmail.com wrote: > A string is either legal or not legal as a key for an associative array. > However, bash accepts certain keys in some contexts but not in other > contexts, It's all about the quoting. > #!/bin/bash > > declare -A foo > > f

Re: certain strings both legal and illegal as associative array keys

2015-03-03 Thread Greg Wooledge
On Tue, Mar 03, 2015 at 01:55:55AM -0600, vampyre...@gmail.com wrote: > > imadev:~$ i="a'b" > > imadev:~$ unset 'foo[$i]' > > However, I did not try that way, because -- according to the bash > documentation -- it shouldn't work. Single quotes should prevent the > expansion of $i. Even knowing n

Re: dead link

2015-03-03 Thread Greg Wooledge
The original bug report says "It should point to X. It's currently pointing to X." where both X's are the same. But this isn't entirely your fault. The link seems to be correct, insofar as it is the same link pointed to from the table of contents, and from the "Next:" header on the previous page

Re: BUG: echo call function

2015-03-04 Thread Greg Wooledge
On Wed, Mar 04, 2015 at 11:42:19AM -0300, x Slack x Ruan wrote: > I understand the use of ''. > But in this case could not be a interrupt call? > So it is no loop, the problem persists even if there is space between the ``. Spaces in the command are not relevant. You are calling yourself recurs

Re: bash-4.3.33 regexp bug

2015-03-05 Thread Greg Wooledge
On Thu, Mar 05, 2015 at 05:07:44PM +, Stephane Chazelas wrote: > bash also supports \s, but that's more for [[:space:]] (so > includes vertical spacing like CR, LF), and you need to use an > intermediary variable: > > r='^some text:\s+([0-9.]+)' > [[ $s =~ $r ]] Woah! What? Where is *that*

Re: bash-4.3.33 regexp bug

2015-03-05 Thread Greg Wooledge
On Thu, Mar 05, 2015 at 05:26:00PM +, Stephane Chazelas wrote: > The bash manual only points to regex(3). > > So it's down to your system's regex library (uses > regcomp(REG_EXTENDED)) which on recent GNU systems supports \s. I see. So it's another nonportable feature like printf '%(%s)T'. G

Re: IFS=: & splitting paths -- (maybe fixed in 4.3?)

2015-03-09 Thread Greg Wooledge
On Sun, Mar 08, 2015 at 11:21:41AM -0600, Eduardo A. Bustamante López wrote: > > alias rs="IFS=\ $'\x09'$'\x0a'" > > The fuck? Just use > alias rs="IFS=\$' \t\n'" or even better, alias rs='unset IFS' rs() { IFS=$' \t\n'; } Aliases... my god, why? > > echo "1st try to split pth:" > > IFS=: ech

Re: certain strings both legal and illegal as associative array keys

2015-03-10 Thread Greg Wooledge
On Mon, Mar 09, 2015 at 08:18:17PM -0500, vampyre...@gmail.com wrote: > This implies to me that escaping the quotes in the unset line would cause the > array code to see the same thing in both cases. That is, > > unset foo[\"a\'b\"] > > would mean that the pre-array code word expansions would r

Re: -i option of set missing in man bash

2015-03-12 Thread Greg Wooledge
On Thu, Mar 12, 2015 at 01:13:18PM -0500, Peng Yu wrote: > One may want to manually set -i option in a bash script for whatever > reason. (In this case, it is to check COLUMNS.) http://mywiki.wooledge.org/BashFAQ/091

Re: read -e deletes extra characters

2015-03-24 Thread Greg Wooledge
On Tue, Mar 24, 2015 at 06:54:14AM +0100, isabella parakiss wrote: > The problem is when I pipe that to a program that prints a prompt. > In the examples, the prompt will be a $ and it will be printed by the > second program in the pipeline. There is no way readline (or whatever the first command

Re: definite way to determine the running shell

2015-03-27 Thread Greg Wooledge
On Fri, Mar 27, 2015 at 07:46:19PM +0100, Christoph Anton Mitterer wrote: > - keeping a complex test suite for many cases up-to-date is not so easy > - since .bashrc and friends are e.g. sourced everytime I start a new > xterm, I'd rather try to avoid having extensive tests there ... why are you

Re: definite way to determine the running shell

2015-03-27 Thread Greg Wooledge
On Fri, Mar 27, 2015 at 08:05:29PM +0100, Christoph Anton Mitterer wrote: > On Fri, 2015-03-27 at 14:56 -0400, Greg Wooledge wrote: > > ... why are you running test suites in your .bashrc?? > > As said, I'd find it nice to have one aliases file for all shells, and > tha

Re: read unexpected reads directory list

2015-03-31 Thread Greg Wooledge
On Tue, Mar 31, 2015 at 06:04:53PM +0300, Filimonov Vadim wrote: > filimonov@filimonov:~/bashbug/bash-4.3$ read -u63 LINE <(echo "*") > bash: read: `/dev/fd/63': not a valid identifier You are missing a < sign here. You probably wanted: read LINE < <(echo "*") It is not safe to assume that the

Re: Incomplete 'command not found' error message if command name contains spaces

2015-04-01 Thread Greg Wooledge
On Wed, Apr 01, 2015 at 05:21:42PM +, Allodoxaphobia wrote: > On an older Ubuntu 10.04 system I still use (I know, I know...) I > get _no_ response. But the return code appears correct: > > jonesy@nix4:~$ uname -a > Linux nix4 2.6.32-39-generic #86-Ubuntu SMP Mon Feb 13 21:47:32 UTC 2012 i686

Re: Second trap invocation is ignored?

2015-04-06 Thread Greg Wooledge
On Sun, Apr 05, 2015 at 09:39:50AM -0700, Scott Bronson wrote: > Hi, I don't understand the behavior of the trap command... > >echo ' > trap "echo $1" DEBUG > ' > ./trapcmd > >source ./trapcmd first >source ./trapcmd second > > I would expect the debug trap to now be '

Re: Second trap invocation is ignored?

2015-04-06 Thread Greg Wooledge
On Mon, Apr 06, 2015 at 10:04:12AM -0500, Eduardo A. Bustamante López wrote: > The `script2' I provided ran with set -T is the closest you'll get to what you > expect, but, since DEBUG runs *before* the source command, it'll not work as > you want. It doesn't matter whether the old DEBUG trap runs

Re: Second trap invocation is ignored?

2015-04-06 Thread Greg Wooledge
On Mon, Apr 06, 2015 at 10:31:49AM -0500, Eduardo A. Bustamante López wrote: > dualbus@yaqui ~ % bash -c 'trap "echo bar" DEBUG; source /dev/fd/0; :' <<< > 'trap "echo foo" DEBUG; :' > bar > foo > bar > > Here, the first `bar' is executed before `source'. Then, we enter a new > `scope', or whate

Re: [Help-bash] make function local

2015-04-13 Thread Greg Wooledge
On Sat, Apr 11, 2015 at 01:27:53PM -0400, Chet Ramey wrote: > On 4/10/15 11:09 AM, Greg Wooledge wrote: > > - Fix the $"..." security hole (I tried and failed). > > http://www.gnu.org/software/gettext/manual/html_node/bash.html > > Yeah, I didn't like

Re: Request to a new feature on read

2015-04-16 Thread Greg Wooledge
On Thu, Apr 16, 2015 at 09:29:56AM -0500, Dan Douglas wrote: > I find myself in need of something along the lines of Python's > `re.split` and `re.findall` all the time. E.g. splitting an ip into an > array of octets. IFS=. read -ra octets <<< "$ip"

Re: Request to a new feature on read

2015-04-16 Thread Greg Wooledge
On Thu, Apr 16, 2015 at 09:39:08AM -0500, Dan Douglas wrote: > On Thu, Apr 16, 2015 at 9:32 AM, Greg Wooledge wrote: > > On Thu, Apr 16, 2015 at 09:29:56AM -0500, Dan Douglas wrote: > >> I find myself in need of something along the lines of Python's > >> `re.spli

Re: Incorrect manage "*" in test -z

2015-04-17 Thread Greg Wooledge
On Fri, Apr 17, 2015 at 09:51:04AM +1000, Guillermo Buritica Tobon wrote: > H have the next bash script code.: > > #!/bin/sh This is not bash. This is sh. > read INPUT Avoid using ALL-CAPS variable names. All-caps names are reserved for internal shell variables, and environment variables like

Re: [Help-bash] make function local

2015-04-17 Thread Greg Wooledge
On Thu, Apr 16, 2015 at 10:38:22PM -0700, Linda Walsh wrote: > It's a trite example, but I do something like: > > > sub gvim () { > array orig_args=($@) gv_files=() gv_ops=() > int use_tab=0 look_for_ops=1 > >sub _exec_gvim() { > array args > ((use_tab)) && args=("-p") > (

Re: [Help-bash] make function local

2015-04-17 Thread Greg Wooledge
On Fri, Apr 17, 2015 at 11:58:15AM -0700, Linda Walsh wrote: > >outerfunc() { > > func() { ...; } > > func args > > unset -f func > >} > >outerfunc The problem is, ALL function definitions (and un-definitions) are global. If there was a "func" defined at the global scope, you've obliterated it. I

Re: [Help-bash] make function local

2015-04-20 Thread Greg Wooledge
On Mon, Apr 20, 2015 at 03:04:00PM -0500, Peng Yu wrote: > Hi Chet, > > I disagree that performance overhead in typical use is `significant'. > > This point is more or less identical to the one I discussed Friday in > > regards to creating huge numbers of variables. Who creates 100,000 > > shell f

Re: Problem with brace expansion

2015-04-23 Thread Greg Wooledge
On Thu, Apr 23, 2015 at 01:01:43AM +0100, Dr Alun J. Carr wrote: > Well, to be strictly conformant with heirloom SysV sh, Nobody cares about compatibility with Bourne shell any more. Not since Solaris finally pulled its head out of its ass and put a POSIX sh in /bin (20 years after everyone else)

Re: (read -r var) vs <(read -r var) behavior

2015-05-19 Thread Greg Wooledge
On Tue, May 19, 2015 at 11:23:49AM +0300, Marcelo Azevedo wrote: > what do you mean here by 'owns' the terminal ? and that in the second > (subshell) example none of these things is true. > in '(command)' is command attached to the terminal and in '<(command)' > command is not? "Attached to" is a

Re: eval a=b\ c

2015-05-26 Thread Greg Wooledge
On Mon, May 25, 2015 at 12:33:53PM -0700, d...@yost.com wrote: > # Echo the arguments, then execute them as a command. > I can't find a way to implement echodo in bash. set -x your code set +x

Re: unset does not act as expected on namerefs

2015-05-26 Thread Greg Wooledge
On Tue, May 26, 2015 at 10:31:34AM -0400, Shawn Wilson wrote: > swilson@swlap1:~/temp$ bash --version > GNU bash, version 4.3.11(1)-release (x86_64-pc-linux-gnu) > swilson@swlap1:~/temp$ cat t.txt > $ome text !n a file| > swilson@swlap1:~/temp$ unset t > swilson@swlap1:~/temp$ t=$(< ./t.txt) > swi

Re: unset does not act as expected on namerefs

2015-05-27 Thread Greg Wooledge
On Tue, May 26, 2015 at 05:02:43PM -0400, Shawn Wilson wrote: > If there's no good reason to keep this as is (some use case where > this might be wanted and breaking backward compatibility - I can't > see anyone actually *wanting* it this way) shouldn't it be changed? > A behavior can be documented

Re: unset does not act as expected on namerefs

2015-06-02 Thread Greg Wooledge
On Mon, Jun 01, 2015 at 09:59:51PM -0400, Shawn Wilson wrote: > I'll preface this by saying I'm not an expert in bash by any > means. However, most languages have a garbage collection facility C does not. Bash (all shells, really) is very strongly influenced by C. > and most > high level languag

Re: unset does not act as expected on namerefs

2015-06-02 Thread Greg Wooledge
On Tue, Jun 02, 2015 at 11:16:27AM -0400, Shawn Wilson wrote: > I would argue that a nameref is a variable type. I suppose you're right, insofar as it has its own special rules that you have to know about. A lot of people wanted declare -n to be more than it is. It's really just syntactic sugar

Re: Change in behaviour between 4.2.53 and 4.3 series

2015-06-04 Thread Greg Wooledge
On Thu, Jun 04, 2015 at 03:25:13PM +1000, Dmitry Mikhin wrote: > 1. are our expectations for waiting for the entire process group > correct? If not, is this a bug in 4.3? That part, unfortunately, I don't know. > 2. if our expectations are wrong, what would be the recommended ways to > achieve

Re: Unexpected parse error in function definition involing grouping braces and redirections

2015-06-16 Thread Greg Wooledge
On Tue, Jun 16, 2015 at 01:56:31PM +0200, Michael Le Barbier Grünewald wrote: > 1>&2 { > printf "$@" > printf '\n' > } Redirections may appear anywhere in a simple command, but may only appear at the END of a compound command. Brace grouping is a compou

Re: Feature : walkthrough lines of stdout

2015-06-17 Thread Greg Wooledge
On Wed, Jun 17, 2015 at 04:05:56AM -0700, Hrazel wrote: > Now it would be nice just to log the last lines on stdout and walk it > through line by line ready to be put to the clipboard. This has nothing to do with bash. You would have to request this kind of feature at the terminal level (where "t

Re: Weird background crashing bug

2015-06-29 Thread Greg Wooledge
On Mon, Jun 29, 2015 at 09:28:11AM +0300, Pierre Gaston wrote: > On Mon, Jun 29, 2015 at 5:54 AM, Braden Best wrote: > > I noticed it when I tried to branch an xterm off into multiple sessions > > and mistyped its name: > > > > `xter m&` I'm assuming the backticks are NOT actually part of the com

Re: Weird background crashing bug

2015-06-29 Thread Greg Wooledge
he background itself, I made a gif. I don't usually embed > or attach gifs via email, so here's a link: http://i.imgur.com/epCwOlI.gif > > What do you make of this? > > --Braden > On Jun 29, 2015 5:59 AM, "Greg Wooledge" wrote: > > > On Mon, Jun 29,

Re: Weird background crashing bug

2015-06-29 Thread Greg Wooledge
ebian_chroot:+($debian_chroot)}\u@\h:\w\$ > > > > Also, just to show that the terminal really *is* crashing, and not > > somehow vanishing into the background itself, I made a gif. I don't usually > > embed or attach gifs via email, so here's a link: > > http://

Re: substitution "read all from fd" silently fails: $(<

2015-07-01 Thread Greg Wooledge
On Wed, Jul 01, 2015 at 10:19:10PM +0300, Ilya Basin wrote: > Want to read whole stdin into variable. > Don't want to spawn new processes (cat). If the data stream does not contain any NUL bytes, you can use: IFS= read -r -d '' variable

Re: bash-4.3 stack smashing

2015-07-09 Thread Greg Wooledge
On Thu, Jul 09, 2015 at 11:44:11AM +0200, Ondrej Oprala wrote: > reproducer: > > PS1="$PS1\$(true)" # command substitution in PS1 seems to be important to > reproduce > wait > ^C > # end of reproducer Confirmed in 4.3.39.

Re: Tab completion misbehaves with newlines

2015-07-15 Thread Greg Wooledge
On Wed, Jul 15, 2015 at 04:28:13PM +0200, Rickard Norlander wrote: > Description: > If a file is created which has a newline in its filename, tab > completion does not work correctly. The part before, and the part after the > newline behave as separate entries for the purpose of completion. It

Re: Tab completion misbehaves with newlines

2015-07-17 Thread Greg Wooledge
On Fri, Jul 17, 2015 at 09:41:04AM -0400, Chet Ramey wrote: > On 7/15/15 11:25 AM, Greg Wooledge wrote: > > I type: > > > > $ cat bad > > > > and press Tab twice. [...] > > So, quoting the filename works around the bug, but readline isn't quite

Re: [Help-bash] extdebug not providing expected results with declare -F

2015-07-22 Thread Greg Wooledge
On Wed, Jul 22, 2015 at 07:26:54AM -0700, Michael Convey wrote: > According to man bash: > > The -F option to declare or typeset will list the function names only (and > optionally the > ?? > source file and line number, if the extdebug shell option is enabled). I have no comment on the extde

Re: cannot declare local variables if they're readonly

2015-07-23 Thread Greg Wooledge
On Thu, Jul 23, 2015 at 01:12:01AM +0200, isabella parakiss wrote: > From variables.c > >The test against old_var's context > level is to disallow local copies of readonly global variables (since I > believe that this could be a security hole). >

Re: echo redirect additional new line

2015-07-23 Thread Greg Wooledge
On Thu, Jul 23, 2015 at 03:41:13PM +0200, Hans Ginzel wrote: > Hello! > > Consider, please, this small script > > echo 1 > echo 1>"a b" > echo 2 > echo 2>"c\nd" Did you intend to write the number "2" to a file, or did you intend to redirect stderr? > Why is there the additional new line between

Re: cannot declare local variables if they're readonly

2015-07-23 Thread Greg Wooledge
On Thu, Jul 23, 2015 at 04:57:42PM +0200, isabella parakiss wrote: > The fact is, I found out this by using BASH_REMATCH, trying to use it in > different functions without interfering with each other. Ah! That changes things. :) imadev:~$ [[ x =~ y ]] imadev:~$ declare -p BASH_REMATCH declare -a

Re: BUG?: (or what's going on?) test for NL == NL fails (bash-4.3.39(3)-release)

2015-08-03 Thread Greg Wooledge
On Sun, Aug 02, 2015 at 01:30:14PM -0700, Linda Walsh wrote: > isatty () { test -c /proc/self/fd/1 ; } This can be done portably with test -t 1 if you want the body of the function to do what the name implies. (Testing for a character device gives false positives if stdout is a tape drive or simi

Re: Worth mentioning in documentation

2015-08-06 Thread Greg Wooledge
On Thu, Aug 06, 2015 at 04:13:30PM +0200, Juanma wrote: > In section ???3.2.4.2 Conditional Constructs??? of Bash docs (both in > ???man??? and in the web), at the end, there is an explanation on combining > expressions, starting with the use of brackets. > > There it would be worth to mention t

Re: Worth mentioning in documentation

2015-08-07 Thread Greg Wooledge
On Fri, Aug 07, 2015 at 10:00:53AM +0200, Juanma wrote: > El Thu 6 of Aug, Greg Wooledge profirió estas palabras: > > I believe you are talking about the section that discusses the [[ ... ]] > > command. > > Yes, you are right. And I mean, concretely, the last part: &

Re: Worth mentioning in documentation

2015-08-10 Thread Greg Wooledge
On Mon, Aug 10, 2015 at 10:18:52AM +0200, Juanma wrote: > > [ is an ordinary command (a "shell builtin") > > Here is another point I find confusing: I thought a "shell builtin" didn't > have a separate binary executable file, like 'cd' (which cd => fail), but > some of them do have such form (whic

Re: -e does not take effects in subshell

2015-08-11 Thread Greg Wooledge
On Tue, Aug 11, 2015 at 11:42:29AM +, PRC wrote: > mybuild() > { > ( > set -e > make > echo "build okay" > ) > } > > mybuild && do_other_stuff http://mywiki.wooledge.org/BashFAQ/105 Since mybuild is invoked as part of a compound command, set -e is suppressed.

Re: Feature Request re: syslog and bashhist

2015-08-12 Thread Greg Wooledge
On Wed, Aug 12, 2015 at 08:00:24AM -0500, John McKown wrote: > Case 2: I'm running bash on my employer's system???. Do I really have an > expectation of privacy on my employer's system? Why would I? In some countries, yes, there is such an expectation. Logging your employees' activities may or ma

Re: Bash ignores case when globbing with character ranges

2015-08-13 Thread Greg Wooledge
On Thu, Aug 13, 2015 at 10:15:18AM -0400, g...@callahans.site wrote: > Description: > bash includes characters of wrong case when globbing with ranges > (i.e., [a-z]), after the first instance. The result of [a-z] in locales other than C or POSIX is implementation- defined. If you wan

Re: Subject: Manual directory stack ambiguity

2015-08-14 Thread Greg Wooledge
On Fri, Aug 14, 2015 at 12:08:07PM +0200, Tim Nielens wrote: > Within the whole manual node, it's never clear whether the directory stack > includes the current directory or not. imadev:~$ bash imadev:~$ popd bash: popd: directory stack empty imadev:~$ dirs ~ *shrug* I don't use these commands, s

Re: Integer Overflow in braces

2015-08-17 Thread Greg Wooledge
On Sat, Aug 15, 2015 at 08:53:55PM -0700, Pasha K wrote: > (gdb) r -c "for x in {1..9223372036854775805}; do echo overflow; done" Brace expansion requires bash to generate and store ALL of those strings in memory simultaneously. I seriously doubt any computer on earth has enough virtual memory to

Re: Integer Overflow in braces

2015-08-18 Thread Greg Wooledge
On Tue, Aug 18, 2015 at 07:54:48AM -0500, Dan Douglas wrote: > IMHO the issue of whether the integer is allowed to overflow is separate from > the question of whether the resulting expansion is "too big". Code that does > an `eval "blah{0..$n}"` is reasonably common and not necessarily stupid.

Re: Parameter Expansion: Case Modification: ${var~} not documented

2015-08-18 Thread Greg Wooledge
On Tue, Aug 18, 2015 at 09:22:07AM -0500, Dan Douglas wrote: > The `~` is obviously inspired by the vim > movement to toggle caps. ~ is standard vi, not a vim extension.

Re: -e does not take effects in subshell

2015-08-18 Thread Greg Wooledge
On Tue, Aug 18, 2015 at 01:49:53PM -0700, Linda Walsh wrote: > Ex: rmx -fr (alias to rm --one-file-system -fr, since rm lacks the > -x switch like 'find, cp, mv, et al.) no longer works to clean > out a directory && stay on *one* file system. When did POSIX or any historical Unix rm have a --one-f

Re: assert built-in

2015-08-19 Thread Greg Wooledge
On Wed, Aug 19, 2015 at 08:39:15AM +, Craig wrote: > It's somewhat cumbersome to have to transport this assert function from > project to project, so it would save a considerable amount of effort and > time if it were built-in. > function assert() { > local lineno=${BASH_LINENO[0]} \ >

Re: -e does not take effects in subshell

2015-08-20 Thread Greg Wooledge
On Tue, Aug 18, 2015 at 03:31:10PM -0700, Linda Walsh wrote: > with 'rm' functionality to remove '/' '.' and '..' was prohibited > by POSIX, though the coreutils version still allows the choice > of the more dangerous removal of '/' with with the --[no-]preserve-root. > > But the more useful "rm

Re: Function name conflict with alias in bash-4.3

2015-08-25 Thread Greg Wooledge
On Tue, Aug 25, 2015 at 06:36:34PM +0200, Corentin Peuvrel wrote: > If you have an alias named "foobar", you can create a function with the > keyword "function" (with or without parenthesis) : > $ function foobar { :; } > > But you cannot if you don't : > $ foobar() {:;} > -bash: syntax error nea

Re: Inconsistent arithmetic evaluation of parameters

2015-09-01 Thread Greg Wooledge
On Tue, Sep 01, 2015 at 12:50:23AM -0400, Clint Hepner wrote: > Repeat-By: > > foo=bar > bar=5 > echo $(( foo ))# produces 5 > echo $(( foo++ )) # produces 5 > echo $foo # produces 6, not bar > echo $bar # produces 5, not 6 bar was never changed from

Re: Inconsistent arithmetic evaluation of parameters

2015-09-01 Thread Greg Wooledge
On Tue, Sep 01, 2015 at 03:13:57PM -0500, Dennis Williamson wrote: > The version of dash I have handy (0.5.7) has math support which IMHO is > broken: > > $ foo=bar > $ bar=5 > $ echo $foo > bar > $ echo $((foo)) > dash: 4: Illegal number: bar > $ echo $(($foo)) > 5 > $ echo $((bar)) > 5 > $ echo

Re: Inconsistent arithmetic evaluation of parameters

2015-09-02 Thread Greg Wooledge
On Wed, Sep 02, 2015 at 10:16:14AM -0500, Dennis Williamson wrote: > The $ is implied. That is completely absurd. (And wrong.)

Re: Inconsistent arithmetic evaluation of parameters

2015-09-02 Thread Greg Wooledge
On Wed, Sep 02, 2015 at 11:24:42AM -0400, Chet Ramey wrote: > On 9/2/15 11:19 AM, Greg Wooledge wrote: > > On Wed, Sep 02, 2015 at 10:16:14AM -0500, Dennis Williamson wrote: > >> The $ is implied. > > > > That is completely absurd. (And wrong.) > > Not exa

Re: [MAN PAGE] bash

2015-09-04 Thread Greg Wooledge
On Fri, Sep 04, 2015 at 04:54:29PM +0200, Julien PRIGENT wrote: > (some HTML stuff about /etc/bash.logout or something) This file is not part of standard bash. It has been compiled as an addition by your operating system vendor/distributor. The FILES section in the standard bash man page looks

Re: 4-byte script triggers null ptr deref and segfault

2015-09-17 Thread Greg Wooledge
On Thu, Sep 17, 2015 at 11:50:44AM -0500, Brian Carpenter wrote: > While fuzzing GNU bash version 4.3.42(1)-release > (x86_64-unknown-linux-gnu) with AFL(http://lcamtuf.coredump.cx/afl), I > stumbled upon a 4-byte 'script' that triggers a null ptr deref and causes a > segfault. > > https://savanna

Re: Misused term "subshell" in §3.3 of the Bash Manual

2015-09-21 Thread Greg Wooledge
On Mon, Sep 21, 2015 at 07:45:25PM +0800, ziyunfei wrote: > "Functions may be exported so that *subshells* automatically have them > defined with the -f option to the export builtin" > > Technically, a child shell process forked/execed by the current shell is not > a real subshell, am I right?

Re: SIGINT handling

2015-09-22 Thread Greg Wooledge
On Mon, Sep 21, 2015 at 10:07:55PM +0100, Stephane Chazelas wrote: > Maybe the test scenario was not clear: > > bash -c 'cmd; echo hi' > > is run from an interactive shell, cmd is a long running > application (the problem that sparked this discussion was with > ping and I showed examples with an

Re: local keyword hides return code of command substitution

2015-09-22 Thread Greg Wooledge
On Tue, Sep 22, 2015 at 10:19:56AM -0400, idal...@home.idallen.ca wrote: > Description: > Adding a "local" keyword to a variable assignment hides the > return code of a command substitution. Same problem in both > bash and dash shells. Yes, this is how it works. If you care abo

Re: '[ --version' should give output, instead a bash error missing re: missing ']'

2015-09-22 Thread Greg Wooledge
On Tue, Sep 22, 2015 at 11:46:05AM -0500, Daniel Simeone wrote: > When I ran 'which [' it stated that the /usr/bin/[ was what was running, > and so I presumed it was in bash. which(1) is an external program, so it doesn't know about shell builtins. Use "type [" in bash intead. I'm quite fond of

Re: command substitution is stripping set -e from options

2015-10-02 Thread Greg Wooledge
On Fri, Oct 02, 2015 at 02:09:21PM +0300, Christoph Gysin wrote: > Since set -e does not work, it means I have to postfix every command > with "|| exit $?": > > f() { > some command || exit $? > more commands --with-args || exit $? > } > > output=$(f) Since it's a function, I would recommend

Re: command substitution is stripping set -e from options

2015-10-02 Thread Greg Wooledge
On Fri, Oct 02, 2015 at 03:53:42PM +0300, Christoph Gysin wrote: > I'm still curious as to why set -e is stripped in the first place? Chet can give the definitive answer, but my take is that it's a huge surprise to someone writing a function independent of the script, or using a function that was

Re: extglob syntax error in function definition

2015-10-08 Thread Greg Wooledge
On Wed, Oct 07, 2015 at 10:44:20PM -0500, Eduardo A. Bustamante López wrote: > > Repeat-By: > > shopt -u extglob > > isnum () ( shopt -s extglob; case "$1" in [1-9]*([0-9])) return 0 ;; > > *) return 1 ;; esac; ) > > Remember that bash parses and interprets the script line-by-line. If yo

Re: command substitution is stripping set -e from options

2015-10-08 Thread Greg Wooledge
On Thu, Oct 08, 2015 at 09:36:59PM +0300, Christoph Gysin wrote: > But this issue brings a new corner case: > > func() { > cmd1 > cmd2 > } > > var=$(func) > > This won't work, because set -e is stripped inside the substitution, > so the whole function runs without error checking.

Re: Something strange with string replacements

2015-10-12 Thread Greg Wooledge
On Sun, Oct 11, 2015 at 04:33:11PM -0700, gaspar@gmail.com wrote: > I was just testing if I could do some things with bash and the I came across > this: > $ tigres="Un tigre, dos tigres, tres tigres" > $ echo ${tigres//[A-Z]/[a-z]} > > tt [a-z][a-z][a-z][a-z][a-z], Ale cto kkk log nfs tes tmp

<    11   12   13   14   15   16   17   18   19   20   >