Re: [Help-bash] difference of $? and ${PIPESTATUS[0]}

2024-04-22 Thread Chet Ramey
On 4/22/24 2:13 AM, felix wrote: I could explain that '$?' is result of bash's if...then...fi group command executed correctly and PIPESTATUS hold result of "most-recently-executed foreground pipeline", but man page say: PIPESTATUS An array variable (see Arrays below) containin

Re: [Help-bash] difference of $? and ${PIPESTATUS[0]}

2024-04-22 Thread Kerin Millar
On Mon, 22 Apr 2024, at 8:56 AM, Oğuz wrote: > On Mon, Apr 22, 2024 at 10:24 AM Kerin Millar wrote: >> I cannot find anything in the manual that concretely explains why bash >> behaves as it does in this instance. > > Me neither, but the current behavior is useful. Take `while false | Very much

Re: [Help-bash] difference of $? and ${PIPESTATUS[0]}

2024-04-22 Thread Greg Wooledge
On Mon, Apr 22, 2024 at 08:13:16AM +0200, felix wrote: > Then after some tests: > > if ls /wrong/path | wc | cat - /wrong/path | sed 'w/wrong/path' >/dev/null > ; then > echo Don't print this' > fi ; echo ${?@Q} ${PIPESTATUS[@]@A} $(( $? ${PIPESTATUS[@]/#/+} )) > > ls: cannot access

Re: [Help-bash] difference of $? and ${PIPESTATUS[0]}

2024-04-22 Thread Martin D Kealey
On Mon, 22 Apr 2024, 18:13 felix, wrote: > Hi, > > Coming on this very old thread: > > [the] man page say[s]: > > PIPESTATUS > An array variable (see Arrays below) containing a list of exit > status values from the processes in the most-recently-executed > foreg

Re: [Help-bash] difference of $? and ${PIPESTATUS[0]}

2024-04-22 Thread felix
Le Mon, Apr 22, 2024 at 10:56:03AM +0300, Oğuz a écrit : > > Me neither, but the current behavior is useful. I agree! Anyway, reading man page, `$?` have to be equivalent to `${PIPESTATUS[-1]}`! which is not always the case. > I've never seen anything like that in a real shell script. I have to

Re: [Help-bash] difference of $? and ${PIPESTATUS[0]}

2024-04-22 Thread Oğuz
On Mon, Apr 22, 2024 at 10:24 AM Kerin Millar wrote: > I cannot find anything in the manual that concretely explains why bash > behaves as it does in this instance. Me neither, but the current behavior is useful. Take `while false | false; do :; done' for example, if bash reported the status of

Re: [Help-bash] difference of $? and ${PIPESTATUS[0]}

2024-04-22 Thread Andreas Kähäri
On Mon, Apr 22, 2024 at 09:15:52AM +0200, felix wrote: > Le Mon, Apr 22, 2024 at 07:44:48AM +0100, Kerin Millar a écrit : > > On Mon, 22 Apr 2024, at 7:13 AM, felix wrote: > > > ... > > > if ls /wrong/path | wc | cat - /wrong/path | sed 'w/wrong/path' > > > >/dev/null ; then > > > echo Don

Re: [Help-bash] difference of $? and ${PIPESTATUS[0]}

2024-04-22 Thread Kerin Millar
On Mon, 22 Apr 2024, at 7:44 AM, Kerin Millar wrote: > On Mon, 22 Apr 2024, at 7:13 AM, felix wrote: >> Hi, >> >> Comming on this very old thread: >> >> On Wed, 4 Dec 2013 14:40:11 -0500, Greg Wooledge wrote: >>> >>> The most obvious difference is that $? is shorter. >>> >>> $? is also POSIX stan

Re: [Help-bash] difference of $? and ${PIPESTATUS[0]}

2024-04-22 Thread felix
Le Mon, Apr 22, 2024 at 07:44:48AM +0100, Kerin Millar a écrit : > On Mon, 22 Apr 2024, at 7:13 AM, felix wrote: > > ... > > if ls /wrong/path | wc | cat - /wrong/path | sed 'w/wrong/path' > > >/dev/null ; then > > echo Don't print this' > > fi ; echo ${?@Q} ${PIPESTATUS[@]@A} $(( $? ${

Re: [Help-bash] difference of $? and ${PIPESTATUS[0]}

2024-04-21 Thread Kerin Millar
On Mon, 22 Apr 2024, at 7:13 AM, felix wrote: > Hi, > > Comming on this very old thread: > > On Wed, 4 Dec 2013 14:40:11 -0500, Greg Wooledge wrote: >> >> The most obvious difference is that $? is shorter. >> >> $? is also POSIX standard (older than POSIX in fact), so it works in sh >> scripts as

Re: [Help-bash] difference of $? and ${PIPESTATUS[0]}

2024-04-21 Thread felix
Hi, Comming on this very old thread: On Wed, 4 Dec 2013 14:40:11 -0500, Greg Wooledge wrote: > > The most obvious difference is that $? is shorter. > > $? is also POSIX standard (older than POSIX in fact), so it works in sh > scripts as well. PIPESTATUS is a Bash extension. > > Finally, note

Re: Help fixing NativeMessaging host: read 32-bit message

2023-06-27 Thread Wiley Young
> It is politics. All human activity is political in nature. Writing for portability is about building a widget that will appeal to a larger group of customers. Thanks for your thoughts. Wiley

Re: help for needs to mention for ((...))

2021-09-19 Thread 積丹尼 Dan Jacobson
OK, so it first looks for exact hits, then does a grep style match. And we see that $ help f|grep :. false: false fc: fc [-e ename] [-lnr] [first] [last] or fc -s [pat=rep] [command] fg: fg [job_spec] for: for NAME [in WORDS ... ] ; do COMMANDS; done for ((: for (( exp1; exp2; exp3 )); do COMMANDS

Re: help for needs to mention for ((...))

2021-09-19 Thread 積丹尼 Dan Jacobson
$ help f|wc -l 72 $ help fo |wc -l 24 $ help for |wc -l 10 $ help for\ |wc -l 14 $ help for\ \( |wc -l 14 $ help for\ \(\(|wc -l 14 So help help's 'If PATTERN is specified, gives detailed help on all commands matching PATTERN." is not telling the whole story about matching.

Re: help for needs to mention for ((...))

2021-09-19 Thread 積丹尼 Dan Jacobson
OK, then "help for" should at least mention that trick to get the rest of the story.

Re: help for needs to mention for ((...))

2021-09-19 Thread Dennis Williamson
On Sun, Sep 19, 2021, 4:07 PM Lawrence Velázquez wrote: > On Sun, Sep 19, 2021, at 3:25 PM, 積丹尼 Dan Jacobson wrote: > > $ help for > > only mentions > >for name [ [ in [ word ... ] ] ; ] do list ; done > > and needs to be updated to mention > >for (( expr1 ; expr2 ; expr3 )) ; do

Re: help for needs to mention for ((...))

2021-09-19 Thread Lawrence Velázquez
On Sun, Sep 19, 2021, at 3:25 PM, 積丹尼 Dan Jacobson wrote: > $ help for > only mentions >for name [ [ in [ word ... ] ] ; ] do list ; done > and needs to be updated to mention >for (( expr1 ; expr2 ; expr3 )) ; do list ; done Not particularly intuitive, but: bash-5.1$ help 'for (('

Re: help adding some features to 5.1

2021-09-01 Thread Ananth Chellappa
Just for me :) I know my productivity will be higher. Eventually I'll do a YouTube video on it. If we see enough adoption, we can consider rolling them in. !$ picking up & from the previous command really is a no no :) On Wed, Sep 1, 2021 at 6:36 PM Lawrence Velázquez wrote: > On Wed, Sep 1, 20

Re: help adding some features to 5.1

2021-09-01 Thread Lawrence Velázquez
On Wed, Sep 1, 2021, at 8:20 PM, Ananth Chellappa wrote: > I hope I can make a genuine contribution at some point. If you're hoping/planning on getting these changes accepted into bash, it might be worth hashing out details with Chet before expending your time and energy. (I am not a contributor,

Re: help adding some features to 5.1

2021-09-01 Thread Ananth Chellappa
Thanks Sincerely Chet. I hope I can make a genuine contribution at some point. On Wed, Sep 1, 2021 at 12:27 PM Chet Ramey wrote: > On 8/31/21 6:38 PM, Ananth Chellappa wrote: > > Hi Team, > >Could I get some help locating portions of the code that would > need > > to be tweaked to add t

Re: help adding some features to 5.1

2021-09-01 Thread Chet Ramey
On 8/31/21 6:38 PM, Ananth Chellappa wrote: > Hi Team, >        Could I get some help locating portions of the code that would need > to be tweaked to add these features? > > If I had the time, I would love to get to know the code, but I have too > much going on in my real job.  > > 1. Intelligen

Re: `help declare' don't show the same document with the online one.

2020-07-28 Thread Hongyi Zhao
On Tue, Jul 28, 2020 at 9:25 PM Chet Ramey wrote: > > > > The online version of the document for declare told the following usage: > > > > > > declare > > declare [-aAfFgilnrtux] [-p] [name[=value] …] > > [...] > > The -p option will display the attributes and values of each name. > > When -p is u

Re: `help declare' don't show the same document with the online one.

2020-07-28 Thread Chet Ramey
> The online version of the document for declare told the following usage: > > > declare > declare [-aAfFgilnrtux] [-p] [name[=value] …] > [...] > The -p option will display the attributes and values of each name. > When -p is used with name arguments, additional options, other than -f > and -F

Re: help for "(( ))" uses straight quotes

2019-09-16 Thread Chet Ramey
On 9/15/19 4:07 PM, Roland Illig wrote: > The help for "(( ))" says: > >> evaluation. Equivalent to "let EXPRESSION". > > All other help topics use `these' quotes. Thanks, it should be let "EXPRESSION", with or without the `' quotes, as it is in the man page. -- ``The lyf so short, the cr

Re: [Help-bash] What are the regex spec for function names?

2019-01-06 Thread Peng Yu
> There is probably no easy regex to match strings bash will tolerate as > a function name without error. The accepted names vary in several > contexts. > > http://pubs.opengroup.org/onlinepubs/9699919799/utilities/V3_chap02.html#tag_18_09_05 > > "The function is named fname; the application shall

Re: [Help-bash] How to run tests/?

2019-01-02 Thread Peng Yu
> Have you tried 'make test'? No, I didn't. I didn't know it was a target. I just followed the README in that directory. -- Regards, Peng

Re: [Help-bash] How to run tests/?

2019-01-01 Thread Eduardo Bustamante
On Tue, Jan 1, 2019 at 10:09 PM Eduardo Bustamante wrote: > > On Tue, Jan 1, 2019 at 9:42 PM Eduardo Bustamante wrote: > > > On Tue, Jan 1, 2019, 8:46 PM Peng Yu, wrote: > >> > >> I got the following errors when I try tests/ in the bash source code. > >> Is it because my sh is just bash? Since I

Re: [Help-bash] Why does ctrl-c behave differently for builtin sleep in a subshell?

2018-12-27 Thread Chet Ramey
On 12/25/18 11:28 AM, Peng Yu wrote: > If I add a command after the builtin sleep, then the EXIT trap will be > triggered upon typing ctrl-C. > > If the last command is removed, then the EXIT trap will not be > triggered upon typing ctrl-C. It's a bug in bash-4.4, fixed in bash-5.0. -- ``The l

Re: "help echo" forgets about "\u"

2018-12-07 Thread Chet Ramey
On 12/7/18 5:27 AM, Egmont Koblinger wrote: > Hi, > > With 4.4 as well as the 20181205 snapshot: the output of "help echo" > doesn't mention the escape characters "\u" and "\U". (They are > mentioned in the manual page.) Thanks, I'll add something. -- ``The lyf so short, the craft so long to le

Re: [Help-bash] Using lastpipe causes function that takes stdin to fail

2018-11-12 Thread Chet Ramey
On 11/12/18 1:35 PM, Jesse Hathaway wrote: > On Mon, Nov 12, 2018 at 12:16 PM Chet Ramey wrote: >> Thanks for the report. This was a bug having to do with the nested >> pipelines and lastpipe, fixed back in August as the result of >> >> https://savannah.gnu.org/support/index.php?109541 > > Thanks

Re: "help" translates arguments of builtin commands but not command description

2018-06-21 Thread Chet Ramey
On 6/21/18 3:41 AM, Ralf Goertz wrote: > Hi, > > I think it is confusing to have the arguments of a builtin command > translated by "help command" but in the subsequent explanation these > arguments ar in english. Assuming you have german locale files for bash > installed you will for example get

Re: [Help-bash] which paradigms does bash support

2018-03-15 Thread Dieter Van Eessen
Hello, >From notes from my perspective: - using the entire filesystem = 'maintaining state' : files ARE state. - all variables (commands and files) are accessible in global scope through absolute path: I think of (command line) programs as functions available in global scope - all variables(script

Re: [Help-bash] which paradigms does bash support

2018-03-15 Thread Greg Wooledge
On Wed, Mar 14, 2018 at 02:11:32PM -0700, Andy Chu wrote: > Shell Has a Forth-like Quality > http://www.oilshell.org/blog/2017/01/13.html Similar to http://mywiki.wooledge.org/WrapperScript :) > Pipelines Support Vectorized, Point-Free, and Imperative Style > http://www.oilshell.org/blog/2017/01/

Re: [Help-bash] which paradigms does bash support

2018-03-14 Thread Andy Chu
I think the best way to ground this type of discussion is to show code. I wrote a couple articles last year that show shell's relation to the broader subject of programming paradigms, with example code: Shell Has a Forth-like Quality http://www.oilshell.org/blog/2017/01/13.html Pipelines Support

Re: [Help-bash] which paradigms does bash support

2018-03-13 Thread Garreau, Alexandre
On 2015-01-26 at 16:05, Pádraig Brady wrote: > It should be noted that shell programming is closely related to > functional programming. […] > > By trying to use filters and pipes instead of procedural shell > statements, you get the advantage of using compiled code, and implicit > multicore suppor

Re: help complete: mention remove all AND restore all

2017-11-10 Thread 積丹尼 Dan Jacobson
> "EB" == Eduardo Bustamante writes: EB> I googled "disable programmable completion bash" and the first result I was just googling for disable bash completion. That's how confusing it is for most users.

Re: help shopt: mention what happens if only optnames are given

2017-11-06 Thread Chet Ramey
On 11/5/17 8:53 PM, 積丹尼 Dan Jacobson wrote: > OK it mentions "Without any option arguments". Then it also needs to > mention "Without any argument at all". Let's see if I can express that clearly in a few words. -- ``The lyf so short, the craft so long to lerne.'' - Chaucer ``Ar

Re: help complete: mention remove all AND restore all

2017-11-06 Thread Chet Ramey
On 11/5/17 11:23 PM, Eduardo Bustamante wrote: > The manual is not supposed to have direct answers to all the possible > questions the user might have. That would just make the manual larger > (it is huge already) and unreadable. It's even less reasonable to put it in the `help' output, which is

Re: help complete: mention remove all AND restore all

2017-11-05 Thread Eduardo Bustamante
On Sun, Nov 5, 2017 at 7:01 PM, 積丹尼 Dan Jacobson wrote: > OK, please on > $ help complete > at "-r" please mention > "To instead toggle on and off PROGRAMMABLE completion, use shopt -[su] > progcomp." > > Reason: there is very little chance the user could Google the right > answer out of the fore

Re: help shopt: mention what happens if only optnames are given

2017-11-05 Thread 積丹尼 Dan Jacobson
OK it mentions "Without any option arguments". Then it also needs to mention "Without any argument at all".

Re: help shopt: mention what happens if only optnames are given

2017-11-05 Thread Dennis Williamson
On Nov 5, 2017 7:05 PM, "積丹尼 Dan Jacobson" wrote: $ help shopt shopt: shopt [-pqsu] [-o] [optname ...] Set and unset shell options. Change the setting of each shell option OPTNAME. Without any option arguments, list all shell options with an indication of whether or not each is

Re: help complete: mention remove all AND restore all

2017-11-05 Thread 積丹尼 Dan Jacobson
OK, please on $ help complete at "-r" please mention "To instead toggle on and off PROGRAMMABLE completion, use shopt -[su] progcomp." Reason: there is very little chance the user could Google the right answer out of the forest of answers out there. (P.S., I am not sure if PROGRAMMABLE should be

Re: help complete: mention remove all AND restore all

2017-11-05 Thread Chet Ramey
On 11/5/17 11:58 AM, 積丹尼 Dan Jacobson wrote: > $ help complete > > -r remove a completion specification for each NAME, or, if no > NAMEs are supplied, all completion specifications > > Add > To later restore them do ... There is no standard way to restore

Re: help complete: mention remove all AND restore all

2017-11-05 Thread 積丹尼 Dan Jacobson
PG> There is no magic way to restore them Actually it also says -pprint existing completion specifications in a reusable format So maybe it should say do I=$(completion -p); completion -r; : your tests; $I but I didn't test it.

Re: help complete: mention remove all AND restore all

2017-11-05 Thread Pierre Gaston
On Sun, Nov 5, 2017 at 6:58 PM, 積丹尼 Dan Jacobson wrote: > $ help complete > > -rremove a completion specification for each NAME, or, if no > NAMEs are supplied, all completion specifications > > Add > To later restore them do ... > > as one often want

Re: Help with GNU Bash source understanding

2017-09-02 Thread Chet Ramey
On 9/2/17 2:16 AM, Jason Mielke wrote: > The first line of builtins/mkbuiltins.c gives the comment: > > /* mkbuiltins.c - Create builtins.c, builtext.h, and builtdoc.c from >a single source file called builtins.def. */ > > Where is builtins.def? This is notational and historical, and mkbuilt

Re: [Help-bash] Bash Trap: How to Get Line Number of a Subprocess with Non-Zero Status

2017-01-02 Thread Chet Ramey
On 1/2/17 4:59 AM, Steve Amerige wrote: > From an end-user's perspective, it is unexpected that the LINENO has the > value of the > beginning of the function instead of the line at which the ERR was caught > by trap. Sure, it's missing functionality. Eduardo's patch was pretty much spot-on. It w

Re: [Help-bash] Bash Trap: How to Get Line Number of a Subprocess with Non-Zero Status

2017-01-02 Thread Steve Amerige
On 12/30/2016 12:50 PM, Chet Ramey wrote: It's the difference between a simple command, which has a line number, and a subshell command, which does not. The subshell command's line number is derived from the execution context, which is relative to the start of

Re: [Help-bash] Bash Trap: How to Get Line Number of a Subprocess with Non-Zero Status

2016-12-30 Thread Chet Ramey
On 12/29/16 10:39 PM, Eduardo Bustamante wrote: > I'm adding the bug-bash list, since I think this is actually a bug in > the parse_comsub function, or maybe in execute_command_internal. I > haven't been able to figure it out yet. What I do know is that these > two should behave the same: > >

Re: [Help-bash] Bash Trap: How to Get Line Number of a Subprocess with Non-Zero Status

2016-12-30 Thread Eduardo Bustamante
On Thu, Dec 29, 2016 at 9:39 PM, Eduardo Bustamante wrote: > I'm adding the bug-bash list, since I think this is actually a bug in > the parse_comsub function, or maybe in execute_command_internal. I > haven't been able to figure it out yet. What I do know is that these > two should behave the sam

Re: [Help-bash] Bash Trap: How to Get Line Number of a Subprocess with N

2016-12-30 Thread Steve Amerige
I've updated the stackoverflow question with more info. I also tested: 1 #!/bin/bash 2 shopt -s extdebug 3 main() { 4 trap 'echo $LINENO' ERR 5 $(ex

Re: [Help-bash] Bash Trap: How to Get Line Number of a Subprocess with Non-Zero Status

2016-12-29 Thread Eduardo Bustamante
On Thu, Dec 29, 2016 at 11:20 AM, Steve Amerige wrote: > I've posted a question to StackOverflow, but I'm hoping the experts here can > chime in. > > http://stackoverflow.com/questions/41346907/bash-trap-how-to-get-line-number-of-a-subprocess-with-non-zero-status > > In essence, I want to know how

Re: [Help-bash] How to make vi-insert mode's ctrl-w work in the 4.3 way?

2016-11-04 Thread Clark Wang
On Fri, Nov 4, 2016 at 10:32 PM, Chet Ramey wrote: > On 11/4/16 6:30 AM, Clark Wang wrote: > > For example, if I have inputted the following after the prompt: > > > > # foo "abc" > > > > In bash 4.3's vi-insert mode, when I press ctrl-w it'll delete the whole > > "abc" (including quotes). But wit

Re: [Help-bash] How to make vi-insert mode's ctrl-w work in the 4.3 way?

2016-11-04 Thread Greg Wooledge
On Fri, Nov 04, 2016 at 10:32:17AM -0400, Chet Ramey wrote: > On 11/4/16 6:30 AM, Clark Wang wrote: > > For example, if I have inputted the following after the prompt: > > > > # foo "abc" > > > > In bash 4.3's vi-insert mode, when I press ctrl-w it'll delete the whole > > "abc" (including quotes)

Re: [Help-bash] How to make vi-insert mode's ctrl-w work in the 4.3 way?

2016-11-04 Thread Chet Ramey
On 11/4/16 6:30 AM, Clark Wang wrote: > For example, if I have inputted the following after the prompt: > > # foo "abc" > > In bash 4.3's vi-insert mode, when I press ctrl-w it'll delete the whole > "abc" (including quotes). But with 4.4 I have to press ctrl-w for 3 times > (one for the right " c

Re: [Help-bash] Changed Behaviour from 4.2 to 4.3

2016-08-05 Thread Chet Ramey
On 8/5/16 10:05 AM, Deniz Adrian wrote: > Hey there, > > I'm observing changed behaviour between 4.2 and 4.3: [set -e not exiting shell if failing command is an if statement test] >> [zined bash-testing]$ cat test_works_in_4.2_breaks_in_4.3 >> #!/bin/bash >> >> set -x >> >> function test_functio

Re: help with rsync and Missing trailing-" in remote-shell command.

2016-06-20 Thread dpich
Thanks for the advise! That did it. The command is working fine now with the following setup: currentuser="$(id -u -n)" OPTS=(-q -avz --delete -e 'ssh -i /home/'$currentuser'/.ssh/id_rsa' --rsync-path='sudo rsync') SRC=(/etc/nginx/) RSYNC_CMD=(rsync) for h in balancer0{1..2} ; do DST=$curren

Re: help with rsync and Missing trailing-" in remote-shell command.

2016-06-20 Thread Greg Wooledge
On Fri, Jun 17, 2016 at 01:57:33PM -0700, dp...@realtruck.com wrote: > OPTS=(-q -avz --delete -e \'ssh -i /home/$currentuser/.ssh/id_rsa\' > --rsync-path=\'sudo rsync\') You want: OTPS=(-q -avz --delete -e "ssh -i /home/$currentuser/.ssh/id_rsa" --rsync-path="sudo rsync") OPTS+=( whatever

Re: [Help-bash] help

2016-03-07 Thread Charles Daffern
On 07/03/16 03:44, Val Krem wrote: > Hi John and all, > > I created several files *.txt and when I execute the this command, > > > autil +10 *txt > > > It is listing the first file only!!! > Your function only deals with 2 arguments, but you are passing it several arguments, not just 2. Bash will

Re: [Help-bash] help

2016-03-06 Thread John McKown
Please reply to the list and not just me. There are a lot of helpful people out there. Perhaps a "reply all"? On Sun, Mar 6, 2016 at 5:26 PM, Val Krem wrote: > Hi John, > Thank you very much! > I chose to put it as a function in my .bashrc. > what happened is that > if I dot give the the two ar

Re: [Help-bash] Source builtin and error handling

2015-12-02 Thread Chet Ramey
On 11/30/15 3:58 PM, Marcin Świgoń wrote: > Dear bash experts, > > Today I came across a strange situation when using set -e, source > builtin and error handling. Thanks for the report. You found a bug in the handling of nested builtins that should ignore the errexit option. Bash needs to resto

Re: [Help-bash] Why BASH_SUBSHELL behaves differently in () and <()?

2015-09-17 Thread ziyunfei
> The expansion is being done in the parent shell, rather than the subshell. But as you said in http://lists.gnu.org/archive/html/help-bash/2015-04/msg00010.html BASHPID is expanded in the subshell, so BASH_SUBSHELL must also be like that. And I found a comment which says: "make the child early,

Re: help builtin generates unaligned results for multicolumn widechars.

2015-08-25 Thread Chet Ramey
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 On 8/22/15 9:59 AM, Mingye Wang (Arthur2e5) wrote: > Version: <= 4.4-alpha > > In bash's `help.def' builtin, wdispcolumn() is used to display `help' > columns. It terminates the string at wcstr[width - 1], with a comment > that assmues each wide chara

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: 'help typeset' doesn't show -n option

2015-04-27 Thread Chet Ramey
On 4/27/15 10:32 AM, Valentin Bajrami wrote: > I'm sure I could use ''declare'' because of the above mentioned reason, but > shouldn't typeset mention it's -n option? Yes, it should. typeset and declare are equivalent. Thanks for catching this. -- ``The lyf so short, the craft so long to lern

Re: [Help-bash] make function local

2015-04-20 Thread Chet Ramey
On 4/20/15 4:04 PM, Peng Yu wrote: >> 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 functions in a single script? The ov

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: [Help-bash] make function local

2015-04-20 Thread Peng Yu
Hi Chet, >>> That's the difference: if you're careful with naming and rigorous about >>> your calling conventions, your one-time-use functions are about as close >>> as you can get to local functions in bash, but you have to pay attention >>> to the declaration's side effects. >> >> There is at le

Re: [Help-bash] make function local

2015-04-20 Thread Chet Ramey
On 4/19/15 10:38 PM, Peng Yu wrote: >> That's the difference: if you're careful with naming and rigorous about >> your calling conventions, your one-time-use functions are about as close >> as you can get to local functions in bash, but you have to pay attention >> to the declaration's side effect

Re: [Help-bash] make function local

2015-04-19 Thread Peng Yu
Hi Chet, >> Eduardo A. Bustamante López wrote: >>> Well, if your scripts are so simple, why use local functions at all? >> --- >> Cleanliness, Hygiene... > > Please, let's not have this argument again. I think you're all using the > term `local function' to mean different things. > > You seem

Re: [Help-bash] make function local

2015-04-19 Thread Chet Ramey
On 4/17/15 6:27 PM, Linda Walsh wrote: > > > Eduardo A. Bustamante López wrote: >> Well, if your scripts are so simple, why use local functions at all? > --- > Cleanliness, Hygiene... Please, let's not have this argument again. I think you're all using the term `local function' to mean diff

Re: [Help-bash] make function local

2015-04-17 Thread Eduardo A . Bustamante López
Hey Linda. I do remember that thread, and I apologize for my words. I honestly try my best here. But it seems that I cannot reply to you without offending you, so, to avoid further offenses I will not reply to any further email from you in the future. I'm sorry that I offended you, it was not my

Re: [Help-bash] make function local

2015-04-17 Thread Linda Walsh
Eduardo A. Bustamante López wrote: Well, if your scripts are so simple, why use local functions at all? --- Cleanliness, Hygiene... You're claiming we invent stuff to make your examples fail, but I don't know anyone that writes such complex code for very simple tasks that can even b

Re: [Help-bash] make function local

2015-04-17 Thread Eduardo A . Bustamante López
Well, if your scripts are so simple, why use local functions at all? You're claiming we invent stuff to make your examples fail, but I don't know anyone that writes such complex code for very simple tasks that can even be done without functions. So, the burden to prove these convoluted approaches a

Re: [Help-bash] make function local

2015-04-17 Thread Linda Walsh
Greg Wooledge wrote: The problem is, ALL function definitions (and un-definitions) are global. --- yeah... If there was a "func" defined at the global scope, you've obliterated it. I don't understand why you don't understand this. --- I don't understand why you think I don't understa

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-17 Thread Linda Walsh
Eduardo A. Bustamante López wrote: On Thu, Apr 16, 2015 at 10:38:22PM -0700, Linda Walsh wrote: [...] AFAIK, _exec_gvim, can only be called from within "function gvim", no? No. Doing this: outerfunc() { func() { ...; } func args unset -f func } outerfunc Doesn't guarantee that `func' wi

Re: [Help-bash] make function local

2015-04-17 Thread Linda Walsh
Greg Wooledge wrote: AFAIK, _exec_gvim, can only be called from within "function gvim", no? That is not correct. In bash, all function definitions are global. imadev:~$ f1() { f2() { echo "I'm f2"; }; }; f1; f2 I'm f2 You left out a few important parts, like f2 being called inside f1

Re: [Help-bash] make function local

2015-04-17 Thread Eduardo A . Bustamante López
On Thu, Apr 16, 2015 at 10:38:22PM -0700, Linda Walsh wrote: [...] > AFAIK, _exec_gvim, can only be called from within "function gvim", no? No. Doing this: outerfunc() { func() { ...; } func args unset -f func } outerfunc Doesn't guarantee that `func' will be only called from outerfunc. If yo

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-16 Thread Linda Walsh
Pierre Gaston wrote: > Is there a particular problem you're trying to solve for which local > functions would be the appropriate solution? Cleanliness. Not polluting the global namespace. Ensuring the function can't be called from outside a function. It's a trite example, but

Re: [Help-bash] make function local

2015-04-16 Thread Chet Ramey
On 4/16/15 11:43 AM, Dan Douglas wrote: > I thought Bash always first splits the identifier from the subscript, > then checks which attributes the variable has set. If it has the > associative array attribute plus a subscript then the subscript is > only processed for expansions and the resulting s

Bash performance when declaring variables (was: Re: [Help-bash] make function local)

2015-04-16 Thread Eduardo A . Bustamante López
On Thu, Apr 16, 2015 at 11:07:34AM -0400, Chet Ramey wrote: [...] > I knew that rang a bell somewhere. mt_hash is a function in the bash > malloc library that keeps track of all allocations and deallocations in > a table. It's part of the debugging that is enabled when you build from > the devel

Re: [Help-bash] make function local

2015-04-16 Thread Dan Douglas
I thought Bash always first splits the identifier from the subscript, then checks which attributes the variable has set. If it has the associative array attribute plus a subscript then the subscript is only processed for expansions and the resulting string is used as the key. If the associative arr

Re: [Help-bash] make function local

2015-04-16 Thread Chet Ramey
On 4/12/15 5:56 PM, Eduardo A. Bustamante López wrote: > Oh, you already have lots of things to do to bother with this :-) > > Anyways, I'll expand them. > > On Fri, Apr 10, 2015 at 04:35:25PM -0400, Chet Ramey wrote: >> On 4/10/15 10:13 AM, Eduardo A. Bustamante López wrote: >> >>> - a faster im

Re: [Help-bash] make function local

2015-04-16 Thread Chet Ramey
On 4/12/15 5:56 PM, Eduardo A. Bustamante López wrote: > Oh, you already have lots of things to do to bother with this :-) > > Anyways, I'll expand them. > > On Fri, Apr 10, 2015 at 04:35:25PM -0400, Chet Ramey wrote: >> On 4/10/15 10:13 AM, Eduardo A. Bustamante López wrote: >> >>> - a faster im

Re: [Help-bash] make function local

2015-04-13 Thread Chet Ramey
On 4/12/15 5:56 PM, Eduardo A. Bustamante López wrote: > Yes. I've been using gprof to study the code paths of some basic functions, > and > it seems like it spends quite some time in the find_variable() and related > functions (IIRC, there was an mt_hash or something function taking up some > pr

Re: [Help-bash] make function local

2015-04-13 Thread Chet Ramey
On 4/13/15 8:33 AM, Greg Wooledge wrote: > 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: [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 the all-or-nothing choice the patch implemen

Re: [Help-bash] make function local

2015-04-12 Thread Eduardo A . Bustamante López
Oh, you already have lots of things to do to bother with this :-) Anyways, I'll expand them. On Fri, Apr 10, 2015 at 04:35:25PM -0400, Chet Ramey wrote: > On 4/10/15 10:13 AM, Eduardo A. Bustamante López wrote: > > > - a faster implementation of the variable lookup code > > What does this mean,

Re: [Help-bash] make function local

2015-04-11 Thread Chet Ramey
On 4/10/15 11:09 AM, Greg Wooledge wrote: > On Fri, Apr 10, 2015 at 09:13:17AM -0500, Eduardo A. Bustamante López wrote: >> Now, for the features in bash that'd be actually useful: >> >> - discipline functions and compound datatypes (like in ksh) >> - a way to do wrap arbitrary OS system calls with

Re: [Help-bash] make function local

2015-04-10 Thread Dan Douglas
On Thu, Apr 9, 2015 at 5:40 PM, Peng Yu wrote: > However, the real problem is that global variable make larger programs > difficult to maintain. Therefore, the problem becomes severe for > people using bash for making bash libraries. Any ad hoc use of bash > can always get away from this prob

Re: [Help-bash] make function local

2015-04-10 Thread Chet Ramey
On 4/10/15 10:13 AM, Eduardo A. Bustamante López wrote: > - a faster implementation of the variable lookup code What does this mean, exactly? Optimizing the existing code paths? (Have at it.) Different semantics? Static as opposed to dynamic scoping? > - a shopt to disable evaluation of shell

Re: [Help-bash] Why COLUMNS is not available, when -i is set?

2015-03-11 Thread Eduardo A . Bustamante López
This seems to be a bug. (I'm Cc-ing bug-bash) When you set the 'i' flag as an option to bash, it works: dualbus@hp ~ % bash -O checkwinsize -ic 'echo "$COLUMNS"' 136 This is because of the special treatment that 'i' gets in shell.c. There are some tests there for the value of 'forced_int

Re: Help output has bad indentation

2015-01-21 Thread Christian Weisgerber
Christian Weisgerber: > The output of "help " suffers from various indentation problems. PS: I ran *.def through expand(1), which is one way to fix the problem, but this also reveals that some help texts run over the 80-column limit when indented by four characters: mapfile, read, test, ... --

Re: [Help-bash] Testing for Shellshock ... combinatorics and latest(Shellshock) Bash Vulnerability...(attn: Chet Ramey)

2014-10-09 Thread Chet Ramey
On 10/9/14, 4:50 PM, Eduardo A. Bustamante López wrote: > Second, once you generate a command, how will your test program know > if it found a bug? It's easy when bash segfaults, but in the case of > shellshock, it wasn't a crash. This is the problem. It's hard to tell whether bash reporting a s

Re: [Help-bash] make error

2014-09-29 Thread Greg Wooledge
On Mon, Sep 29, 2014 at 05:11:52PM +0800, ??? wrote: > /bin/echo: line 1: Mon: command not found > make: *** [.build] Error 127 This is just a guess, but it looks like you tried to build bash in a shell where you had previously been testing for shellshock-type vulnerabilities, and you have a conta

Re: [Help-bash] brace expansion in non-C locales

2013-03-13 Thread Chet Ramey
On 3/13/13 9:13 AM, Hans J. Albertsson wrote: > > I fully expected the brace expression {Z..Ö} to epand to Z Å Ä Ö in the > sv_SE.ISO8859-1 locale. > > Why is brace expressions limited to C locale behaviour? Because there is no portable way to enumerate a collating sequence, no portable way to d

Re: [Help-bash] opposite of 'shift'

2012-07-14 Thread Chet Ramey
> On 2/17/12 8:25 AM, Pierre Gaston wrote: > > This is probably because bash lacks an easy way to pass an array by > > reference to a function. > > This is where a requested feature could make it into bash. This seems to > be a common problem with no clean solution (one can only get so far with

Re: [Help-bash] /proc/.../cdrom/info not completely read

2012-04-30 Thread Greg Wooledge
On Mon, Apr 30, 2012 at 09:57:16AM -0400, Chet Ramey wrote: > Bash reads 128 characters at a time and uses lseek to move the file pointer > back to the last character `read' consumes. The negative offset to lseek > causes some kind of problem, but it doesn't return an error. When bash > goes back

  1   2   >