RFE: Make `printf -v var` support positional parameters

2024-12-05 Thread Clark Wang
It would be easier to manipulate positional params if we can write like `printf -v 1`.

Re: "complete -o filenames" sometimes not working

2024-11-12 Thread Clark Wang
On Mon, Nov 11, 2024 at 10:51 PM Grisha Levit wrote: > > If your goal is to have readline do the quoting for you > Yes this is what I want to do. > , without treating the completions as filenames, the next version of bash > (5.3, see the 'devel' branch in the git repo) will have the '-o fullqu

Re: "complete -o filenames" sometimes not working

2024-11-09 Thread Clark Wang
On Sat, Nov 9, 2024 at 1:48 AM Chet Ramey wrote: > > OK. You asked for the completions to be treated as filenames. When > readline displays the possible completions for filenames, it doesn't > display the full pathname -- just the portion after the final slash. > The words with ProxyCommand= are

"complete -o filenames" sometimes not working

2024-11-07 Thread Clark Wang
See the following reproduce example: $ cat ssh_compspec COMP_WORDBREAKS=${COMP_WORDBREAKS//[=:]/} function _ssh() { local cur="$2" pre="$3" local options=( ProxyCommand='/usr/bin/nc -x host:port %h %p -X 5' ProxyCommand='/usr/bin/nc -x host:port %h %p -X connect' C

Re: [5.3-alpha] ">& /some/file" would fail when /some/file already exists

2024-04-25 Thread Clark Wang
On Fri, Apr 26, 2024 at 2:53 AM Chet Ramey wrote: > > I can't reproduce it on macOS. > > $ ./bash --norc > $ touch some.file > $ echo >&some.file > $ rm some.file > $ touch /tmp/file > $ echo >& /tmp/file > $ rm /tmp/file > $ echo $BASH_VERSION > 5.3.0(1)-alpha I was using Debian (not sure about

Re: Bash-5.3-alpha available

2024-04-25 Thread Clark Wang
On Tue, Apr 23, 2024 at 9:20 PM Chet Ramey wrote: > [..] > > and from the bash-5.3-testing branch in the bash git repository > (http://git.savannah.gnu.org/cgit/bash.git/log/?h=bash-5.3-testing). > You can use > > git clone --branch bash-5.3-testing git://git.savannah.gnu.org/bash.git > > to clone

[5.3-alpha] ">& /some/file" would fail when /some/file already exists

2024-04-25 Thread Clark Wang
(I'm using the "devel" branch as the "bash-5.3-testing" branch failed to build for me. HEAD: 8c8daff1e3661c) To reproduce: $ bash53 --norc bash53-5.3# touch /tmp/file bash53-5.3# echo >& /tmp/file bash53: /tmp/file: File exists bash53-5.3#

Re: bash encountered a coredump issue with stepping on memory

2023-12-11 Thread wang yuhang
> Is this at the same point as the core dump in your previous message? yes

Re: bash encountered a coredump issue with stepping on memory

2023-12-06 Thread wang yuhang
> The initialize_shell_variables function is processing env. When the for loop > reaches env[16], glibc needs to use the main_arena.top variable. However, the > value in the address pointed to by the top variable is overwritten by env[15], > causing a glibc exception and resulting in a cor

Re: bash encountered a coredump issue with stepping on memory

2023-12-06 Thread wang yuhang
> Hi. This appears to happen when creating a shell variable from the initial > environment. I can't reproduce it. If you can find a way to reliably > reproduce it, please let me know and we can work on it. So far, we have encountered this issue three times in our environment. The following is one

Re?? bash encountered a coredump issue with stepping on memory

2023-12-05 Thread wang yuhang
> Hi. This appears to happen when creating a shell variable from the initial > environment. I can't reproduce it. If you can find a way to reliably > reproduce it, please let me know and we can work on it. I'm sorry, the environment is quite complex and I couldn't find a way to reliably reproduc

bash encountered a coredump issue with stepping on memory

2023-12-04 Thread wang yuhang
Hi A bash coredump has appeared in my environment, the stack information displayed by GDB is as follows: #0 __pthread_kill_implementation (threadid=

git commit for 5.2 patch 16 added a "tags" file

2023-11-12 Thread Clark Wang
commit 4214b0e12b4345c970d4d50705b1443441baedf8 Author: Chet Ramey Date: Fri 2023-11-10 05:39:38 +0800 Bash-5.2 patch 16: fix for a crash if one of the expressions in an arithmetic for command expands to NULL M execute_cmd.c M patchlevel.h A tags I guess it's not intenti

Re: remove empty '' in ${var@Q} result?

2023-08-20 Thread Clark Wang
On Wed, Nov 8, 2017 at 9:46 PM Chet Ramey wrote: > On 11/7/17 11:38 PM, Clark Wang wrote: > > > I made a patch (also attached). Please see if it's ok. > > > > > > Updated by dealing with empty strings (and malloc'ing 2 more bytes) > >

Performance difference between different versions of bash

2023-06-08 Thread wang yuhang
Hi I found that there is a huge difference in performance between different versions of bash when there are a large number of environment variables in my system. The steps to reproduce are as follows?? $ for i in `seq 1`; do export TEST_ENV_$i=$i; done $ time echo `date` In bash-4.3, it

text similar to JSON can cause memory of bash to become abnormally large

2023-05-24 Thread wang yuhang
hi I accidentally copied a section of JSON text to the terminal and executed it, which resulted in a system crash.Bash version is 5.1.8. Later, I reproduced it and found that when I executed the following command, the memory usage of bash became very large. $ [{"key":"1","key":"1","key"

eval '`' reports error but $? is still 0

2023-05-10 Thread Clark Wang
See the following example (with 5.2.15): bash-5.2$ PS1='$? >> ' 0 >> eval '`' bash: unexpected EOF while looking for matching ``' 0 >><-- press ENTER 2 >><-- now $? is 2 It looks like the failed eval '`' is still waiting for some input?

Re: The memory occupied by bash has been increasing due to the fork bomb

2023-03-10 Thread wang yuhang
> First, systemd will send a sigterm to bash, but in bash-5.1, the bash process will not be killed. this was caused by a > > > change in bash 5.1. The modified change information is as follows > ``` > sss. Fix a bug where receiving SIGTERM from a different process while readline was active could

The memory occupied by bash has been increasing due to the fork bomb

2023-03-10 Thread wang yuhang
Hello ! I am now doing a test on the fork bomb with the command `:(){:|:&};:` and set `ulimit - c 1000`. And everything was well in bash-5.0, but there was a problem in bash-5.1.  The main performance is that the system memory has been rising, and then the kernel appears the oom, I found that

Re: Nested expansion in heredoc fails

2022-12-14 Thread wang yuhang
On 12/13/22 12:42 PM, wang yuhang wrote:> This modification&nbsp;has been changed when dealing with '$(',&nbsp;It seems > to have missed the right bracket.&nbsp;Maybe we should add this bracket. It seems that there is something wrong with this patch, It's tru

Re: Nested expansion in heredoc fails

2022-12-14 Thread wang yuhang
Hello  In bash-5.2, There is one modification: fix to expand $'...' and $"..." in certain word expansions while expanding lines of here-document data This modification has been changed when dealing with '$(', It seems to have missed the right bracket. Maybe we should add this bracket. I hope

[bash-5.2] array assignment caused bash to stop saving history

2022-06-15 Thread Clark Wang
Very often Bash 5.2 would suddenly stop saving command history which has been confusing me for quite some time. Today I did some debugging and came up with the following minimal scenario to reproduce the problem. $ bash --version GNU bash, version 5.2.0(18)-beta (x86_64-apple-darwin21.5.0) Copyri

Re: RFE: new syntax for command substitution to keep trailing newlines?

2021-01-27 Thread Clark Wang
On Wed, Jan 27, 2021 at 4:40 PM Clark Wang wrote: > On Wed, Jan 27, 2021 at 12:14 PM Clark Wang wrote: > >> For example, we can use ${( ... )} which is now wrong syntax. >> >> $ v=${( command ... )} >> bash: ${( command ... )}: bad substitution >> &g

Re: RFE: new syntax for command substitution to keep trailing newlines?

2021-01-27 Thread Clark Wang
On Wed, Jan 27, 2021 at 12:14 PM Clark Wang wrote: > For example, we can use ${( ... )} which is now wrong syntax. > > $ v=${( command ... )} > bash: ${( command ... )}: bad substitution > Or keep it similar to $(cmd), like: $(& cmd ...) $(; cmd ...) $(| cmd ...)

RFE: new syntax for command substitution to keep trailing newlines?

2021-01-26 Thread Clark Wang
For example, we can use ${( ... )} which is now wrong syntax. $ v=${( command ... )} bash: ${( command ... )}: bad substitution

Re: Bash 5.1: rl_readline_version = 0x801 (shouldn't it be 0x0801 ?)

2020-12-07 Thread Clark Wang
On Tue, Dec 8, 2020 at 12:36 PM Testing Purposes < raspberry.teststr...@gmail.com> wrote: > But Readline's official documentation specifically chose an example with a > leading zero — 0x0402. It says that Readline 4.2 should have a version > value of 0x0402, not 0x402. > Could you point me to wh

Re: Bash 5.1: rl_readline_version = 0x801 (shouldn't it be 0x0801 ?)

2020-12-07 Thread Clark Wang
On Tue, Dec 8, 2020 at 10:04 AM Testing Purposes < raspberry.teststr...@gmail.com> wrote: > -- > readline.h defines a C preprocessor variable that should be treated as an > integer, As it says it's an integer. > RL_READLINE_VERSION, which may be used to conditionally compile > applicat

Re: is it a bug

2020-11-16 Thread Clark Wang
On Mon, Nov 16, 2020 at 9:38 PM Robert Elz wrote: > > Personally I'd go further and suggest that no-one should ever use aliases > for anything, ever ... > I don't understand why people "hate" aliases so much. :) For me it's much simpler/shorter than functions. And the "alias" command (without an

Re: possible bugs with colored-stats

2020-10-28 Thread Clark Wang
On Thu, Oct 29, 2020 at 4:11 AM Arnaud wrote: > > Description: > I have colored my prompt with colors, using PS1 and PS0. > > PS1 ends with a color definition, so the command entered is > colored. > PS0 resets the color so the output has the standard colors. > I ha

bug-bash@gnu.org

2020-09-22 Thread Clark Wang
On Tue, Sep 22, 2020 at 5:07 PM Robert Elz wrote: > > With -t, there's no pty, when the shell exits, everything ends up > closed - but the mechanism for this escapes me (what bash &/or sshd > sees differently). You'd do better to ask on an ssh related list > I expect. > Found the question at h

bug-bash@gnu.org

2020-09-22 Thread Clark Wang
On Tue, Sep 22, 2020 at 2:01 PM Robert Elz wrote: > Date:Tue, 22 Sep 2020 10:02:07 +0800 > From:Clark Wang > Message-ID: < > cadv8-ogf0hev-ckegxy9dq1ypcz4bdpkjy_7aex83o1db93...@mail.gmail.com> > > | In an interactive shell (in case th

bug-bash@gnu.org

2020-09-21 Thread Clark Wang
In an interactive shell (in case this matters), run bash -c 'sleep 5 &' and it exits immediately without waiting for the sleep to complete. But ssh user@host 'sleep 5 &' (with bash as the login shell) would wait for sleep to complete. Why the difference? Thanks. -clark

"shell-expand-line" wrongly(?) expanded $'foo' to $foo

2020-07-01 Thread Clark Wang
See the following example (tested with bash 5.0.7): # bind -q shell-expand-line shell-expand-line can be invoked via "\e\C-e". # echo $PWD # press ESC C-e # echo /root # echo $( pwd ) # press ESC C-e # echo /root # echo $'foo'# press ESC C-e # echo $foo Is this a bug? -clark

An exported function is malformed if it contains a nested function definition with heredoc

2020-03-06 Thread Sherwood Wang
Configuration Information [Automatically generated, do not change]: Machine: x86_64 OS: linux-gnu Compiler: gcc Compilation CFLAGS: -g -O2 -fdebug-prefix-map=/build/bash-2bxm7h/bash- 5.0=. -fstack-protector-strong -Wformat -Werror=format-security -Wall -Wno-parentheses -Wno-format-security uname ou

Different history expansion behaivor: true `# # !xxx` vs. true `# !xxx`

2020-03-02 Thread Clark Wang via Bug reports for the GNU Bourne Again SHell
This is from stackoverflow ( https://stackoverflow.com/questions/60166019/ ) and it looks like a bug: $ bash --version GNU bash, version 5.0.7(3)-release (x86_64-pc-linux-gnu) Copyright (C) 2019 Free Software Foundation, Inc. License GPLv3+: GNU GPL version 3 or later

Re: Fwd: Don't set $?=130 when discarding the current command line (not run yet) with CTRL-C?

2019-12-23 Thread Clark Wang
Hi Chet, On Fri, Nov 22, 2019 at 12:02 AM Chet Ramey wrote: > On 11/20/19 9:27 PM, Clark Wang wrote: > > It's quite common for people to press CTRL-C to discard the current > command > > line. This is harmless actually for most times except when people include > >

Re: Fwd: Don't set $?=130 when discarding the current command line (not run yet) with CTRL-C?

2019-11-22 Thread Clark Wang
On Fri, Nov 22, 2019 at 12:02 AM Chet Ramey wrote: > > This behavior dates from at least 2009 and was added at user request so > they could tell exactly that: whether or not entering the last command had > been interrupted by a signal. > Curious why people care about this? -clark

Fwd: Don't set $?=130 when discarding the current command line (not run yet) with CTRL-C?

2019-11-20 Thread Clark Wang
It's quite common for people to press CTRL-C to discard the current command line. This is harmless actually for most times except when people include $? in $PS1. I also show $? in red color when it's not 0 so it's more noticeable. So is it OK to not change $? when people are pressing CTRL-C to disc

Re: Forgets color when resizing with newline in prompt

2019-10-08 Thread Clark Wang
On Sun, Oct 6, 2019 at 12:17 AM ao2 wrote: > [...] > > Description: > > I noticed that when there is a newline in the prompt bash "forgets" > about ANSI color sequences when the window is resized. I am not > sure > f this is general for other kinds of ANSI escape codes. >

Re: Where is GLOBAL_COMMAND?

2019-01-21 Thread Clark Wang
On Tue, Jan 22, 2019 at 1:32 PM Peng Yu mailto:pengyu...@gmail.com>> wrote: Hi, GLOBAL_COMMAND is mentioned as a global variable. But I don't find it. Is it renamed to something else? execute_cmd.c 373- 374-/* Execute the command passed in COMMAND. COMMAND is exactly what 375: read_command ()

bash5: "progcomp_alias" and "complete -D"

2019-01-09 Thread Clark Wang
Seems like if there's "complete -D" defined then "progcomp_alias" would never work. So does it make more sense to make "progcomp_alias" has higher priority than "complete -D"?

Re: FIFO race condition on SunOS kernels

2019-01-02 Thread Clark Wang
On Wed, Jan 2, 2019 at 8:38 PM Vladimir Marek wrote: > > > > Thanks, that's good to have confirmed! It was hoping as much -- it would > > have been hard to believe that something this basic is broken on Solaris > in > > general. > > Heh :) I am heavy shell scripter/user and I have found multiple

bash-5.0-beta2 breaks ``complete -D''

2018-11-30 Thread Clark Wang
Hi Chet, Just tried 5.0-beta2 and it broke my completion rules. It can be reproduced with the following steps: # complete -r # foo() { true; } # complete -o default -o bashdefault -D -F foo # cd /<-- Here it does not list dirs under `/'. Works fine with 4.4. Please take a look. -clark

Re: remove empty '' in ${var@Q} result?

2018-11-28 Thread Clark Wang
On Wed, Nov 8, 2017 at 9:46 PM Chet Ramey wrote: > On 11/7/17 11:38 PM, Clark Wang wrote: > > > I made a patch (also attached). Please see if it's ok. > > > > > > Updated by dealing with empty strings (and malloc'ing 2 more bytes) > >

Re: Variables can’t contain NUL

2018-06-20 Thread Clark Wang
On Wed, Jun 20, 2018 at 10:22 PM, George wrote: > > Personally I do think some method of handling arbitrary binary data in the > shell would be a welcome addition (and I think zsh provides that - don't > remember if ksh does) > Ksh93 has "typeset -b" which defines vars for binary data (actually

Re: Case of set -e not being in effect in a subshell.

2018-06-11 Thread Clark Wang
On Mon, Jun 11, 2018 at 6:12 PM, Bartłomiej Palmowski wrote: > > The issue is: > $ cat bad > ( > set -e > false > echo "Shouldn't happen?" > ) && : > $ bash ./bad ; echo $? > Shouldn't happen? > 0 > $ cat good > ( > set -e > false > echo "Shouldn't happen?" > ) > $ bash ./

Re: cat<(echo text) not same as cat <(echo text)

2018-06-04 Thread Clark Wang
On Mon, Jun 4, 2018 at 11:48 AM, Edward Huff wrote: > That is unexpected. > I agree it may look "unexpected" because "cat

Re: why is dash confused with underscore in autocompletion?

2018-05-29 Thread Clark Wang
On Wed, May 30, 2018 at 7:15 AM, L A Walsh wrote: > While I certainly don't mind having an option > to include -_ as case-variations, I don't really like having it > as a standard or a default > I never know there's such a "completion-map-case" option. It is by default OFF.

Re: Bash patches format

2018-05-29 Thread Clark Wang
On Wed, May 30, 2018 at 8:25 AM, Marty E. Plummer wrote: > > If people are willing to do the conversion between patch formats for > their > > own purposes, more power to them. I don't see any compelling reason to > > change the format I use. > > > Could I at least convince you to start doing -p1,

weird bash5 bug with ``for i; do echo; done; echo in''

2018-03-24 Thread Clark Wang
Hi Chet, Today I compiled bash5 (using default configuration) from the devel branch (f602026a0ce - commit bash-20180316 snapshot) on macOS and found it breaks one of my rc files. After some time of debugging I have the following minimal example to reproduce the problem: $ bash5 -c 'for i; do echo

Re: compgen -W doesn't split wordlist containing single quotes

2018-03-19 Thread Clark Wang
On Mon, Mar 19, 2018 at 9:52 PM, Chet Ramey wrote: > > `-o filenames' would append `/' to a word if the word is coincidentally a > > real existing dir name. How can I ask it not to append the `/'? > > You can't. That's the implication from my second paragraph. > OK. I'll stick with my 2-pass sh-

Re: compgen -W doesn't split wordlist containing single quotes

2018-03-17 Thread Clark Wang
On Sun, Mar 18, 2018 at 1:18 AM, Chet Ramey wrote: > On 3/17/18 12:16 AM, Clark Wang wrote: > > On Sat, Mar 17, 2018 at 1:00 AM, wrote: > > > >> > >> It works correctly if the single quote is itself quoted. Our test > wordlist > >> would then be:

Re: compgen -W doesn't split wordlist containing single quotes

2018-03-17 Thread Clark Wang
On Sat, Mar 17, 2018 at 7:32 PM, Paulo Marcel Coelho Aragão < marcelpa...@gmail.com> wrote: > > Actually every word in the -W "wordlist" needs to be sh-quoted twice > (with > > ``printf %q'' or the new ``${var@Q}'' syntax). It'll be a bit easier if > you > > use an array. > > On a second thought,

Re: compgen -W doesn't split wordlist containing single quotes

2018-03-16 Thread Clark Wang
On Sat, Mar 17, 2018 at 1:00 AM, wrote: > > It works correctly if the single quote is itself quoted. Our test wordlist > would then be: "foo\'bar aaa bbb" > > paulo@monk:~/tmp$ compgen -W "foo\'bar aaa bbb" -- a > aaa > paulo@monk:~/tmp$ compgen -W "foo\'bar aaa bbb" -- b > bbb > paulo@monk:~/tmp

Re: coding standards

2018-03-06 Thread Clark Wang
I don't know much about bash's source code so I cannot comment much. And this kind of arguments are quite opinion based which are not simple yes/no questions. And I believe one thing - the world is not perfect. :) -clark On Tue, Mar 6, 2018 at 8:26 AM, don fong wrote: > Clark, > > Just took a l

Re: coding standards

2018-03-04 Thread Clark Wang
On Mon, Mar 5, 2018 at 9:13 AM, don fong wrote: > Clark, thanks for your answer. > > I use ``if (flag)'' only when `flag' is a boolean. > > > but in this case, it *is* a boolean, as i stated, and as can be seen in > subst.c: > > +{ > + if (check_nullness) > + report_error (_("%s

Re: coding standards

2018-03-04 Thread Clark Wang
On Sun, Mar 4, 2018 at 5:15 AM, don fong wrote: > admittedly this is a very minor point, but i am curious. this has to do > with coding standards for bash source. > > consider an if statement in C (or bash, for that matter). which is form is > better? > > Form (A): > > if (flag) > X

Re: misleading error message from variable modifier

2018-03-01 Thread Clark Wang
On Fri, Mar 2, 2018 at 12:37 PM, don fong wrote: > Chet, thanks. in subst.c there is code that looks similar to what i had > suggested. but i don't see the tests that i submitted. i also don't see > the change listed in CHANGES? > It's in the file CWRU/CWRU.chlog:

Re: Unset array doesn't work

2018-02-26 Thread Clark Wang
On Mon, Feb 26, 2018 at 11:07 PM, Greg Wooledge wrote: > On Mon, Feb 26, 2018 at 09:57:10AM -0500, Clint Hepner wrote: > > If necessary, you can define a global (at the expense of a single > subprocess) > > > > myIFS=$(printf ' \t\n') > > That actually won't work, because $(...) strips the tr

Re: misleading error message from variable modifier

2018-02-23 Thread Clark Wang
On Sat, Feb 24, 2018 at 11:20 AM, don fong wrote: > > i would like to submit this change for inclusion in bash. how should i > proceed? > It's very common to send patches directly to this mailing list. I believe it's also OK to send only to Chet. :)

Re: Unset array doesn't work

2018-02-12 Thread Clark Wang
On Mon, Feb 12, 2018 at 3:23 PM, Nikolai Kondrashov wrote: > >> Take a look at these links: >> >> - http://wiki.bash-hackers.org/commands/builtin/unset >> - http://www.fvue.nl/wiki/Bash:_Passing_variables_by_reference >> > > Thanks, Clark! However, I find it difficult to follow the explanatio

Re: Unset array doesn't work

2018-02-11 Thread Clark Wang
On Mon, Feb 12, 2018 at 2:45 PM, Nikolai Kondrashov wrote: > On 02/12/2018 08:41 AM, Nikolai Kondrashov wrote: > >> inner() { >> unset res >> > > Oh, and duplicating this line fixes the issue. > Take a look at these links: - http://wiki.bash-hackers.org/commands/builtin/unset -

Re: Quoting and string comparison

2018-02-08 Thread Clark Wang
On Thu, Feb 8, 2018 at 9:05 PM, Jaan Vajakas wrote: > Hi! > > I noticed a weird behavior. Is it a bug? > > Namely, why does > > echo "$(for f in a b c; do if [[ \"$f\" > b ]]; then echo "$f > b"; else > echo "$f <= b"; fi; done)" > Should be: echo "$(for f in a b c; do if [[ $f > b ]]; then e

Re: Feature request: PROMPT_COMMANDS array variable

2018-01-23 Thread Clark Wang
On Wed, Jan 24, 2018 at 2:23 AM, Daniel Colascione wrote: > Right now, PROMPT_COMMAND gives a shell command to run before displaying > the prompt. It's common these days to include in one's bash configuration > numerous packages from different sources that *all* want to run code at > PROMPT_COMMA

Re: set $'\001'; v=$* converted $'\001' to $'\001\001'

2018-01-17 Thread Clark Wang
On Mon, Jan 15, 2018 at 11:44 PM, Chet Ramey wrote: > On 1/15/18 1:26 AM, Clark Wang wrote: > > See following example: > > > > [STEP 100] # echo $BASH_VERSION > > 4.4.12(4)-release > > [STEP 101] # set -- $'\001' > > [STEP 102] # v=$* > > [S

set $'\001'; v=$* converted $'\001' to $'\001\001'

2018-01-14 Thread Clark Wang
See following example: [STEP 100] # echo $BASH_VERSION 4.4.12(4)-release [STEP 101] # set -- $'\001' [STEP 102] # v=$* [STEP 103] # printf '%q\n' "$v" $'\001\001' [STEP 104] #

Problem after removing keybinding for bind -m vi-insert '"jj": "\e\e"'

2017-11-20 Thread Clark Wang
[STEP 100] # echo $BASH_VERSION 4.4.12(4)-release [STEP 101] # bind -m vi-insert '"jj": "\e\e"' [STEP 102] # bind -X "jj": "\e\e" [STEP 103] # bind -r jj [STEP 104] # bind -X [STEP 105] # <-- Here when I press j it still waits for about 1 second to show up.

Re: remove empty '' in ${var@Q} result?

2017-11-07 Thread Clark Wang
On Tue, Oct 31, 2017 at 3:53 PM, Clark Wang wrote: > On Tue, Oct 31, 2017 at 3:25 PM, Clark Wang wrote: > >> On Mon, Oct 30, 2017 at 10:41 PM, Chet Ramey wrote: >> >>> >>> This is an effect of using single quotes in the @Q operator. If you want >>&g

Re: remove empty '' in ${var@Q} result?

2017-11-07 Thread Clark Wang
On Mon, Oct 30, 2017 at 8:35 PM, Greg Wooledge wrote: > > What's the bug? They are equivalent. > It's not a bad thing if we can make the language a bit more elegant unless the cost is not worth it. > > If you mean "I would like bash to perform a second optimization pass > over the result of ${

Claim `declare' as a special command in manual?

2017-11-07 Thread Clark Wang
For now the `declare' command is under SHELL BUILTIN COMMANDS in the man page so people may think bash parses the command line parameters the same way as other built-in commands which is not true. [STEP 100] # echo $BASH_VERSION 4.4.12(4)-release [STEP 101] # declare -a arr=() [STEP 102] #

Re: remove empty '' in ${var@Q} result?

2017-10-31 Thread Clark Wang
On Tue, Oct 31, 2017 at 3:25 PM, Clark Wang wrote: > On Mon, Oct 30, 2017 at 10:41 PM, Chet Ramey wrote: > >> >> This is an effect of using single quotes in the @Q operator. If you want >> to single-quote a string containing single quotes, this is how you do it. >

Re: remove empty '' in ${var@Q} result?

2017-10-31 Thread Clark Wang
On Mon, Oct 30, 2017 at 10:41 PM, Chet Ramey wrote: > > This is an effect of using single quotes in the @Q operator. If you want > to single-quote a string containing single quotes, this is how you do it. > I made a patch (also attached). Please see if it's ok. Tested with arr=('' a \' \'\' \'\

${var@Q}: don't quote unless necessary?

2017-10-29 Thread Clark Wang
See following example: [STEP 100] # echo $BASH_VERSION 4.4.12(2)-release [STEP 101] # v=abc [STEP 102] # printf '%q\n' $v abc [STEP 103] # printf '%s\n' "${v@Q}" 'abc' [STEP 104] # Is it possible to not quote the result since there's no special chars in the string? I would expect ${var@Q} to prod

Re: Documentation issue

2017-10-29 Thread Clark Wang
On Fri, Oct 27, 2017 at 3:28 PM, Eli Barzilay wrote: > On Fri, Oct 27, 2017 at 2:37 AM, Clark Wang wrote: > > > > What `unset' does is special but there's nothing special when parsing > > the command and bash even does not care if it's built-in command or &

remove empty '' in ${var@Q} result?

2017-10-29 Thread Clark Wang
See following example: [STEP 100] # echo $BASH_VERSION 4.4.12(2)-release [STEP 101] # v=\'\' [STEP 102] # printf '%q\n' "$v" \'\' [STEP 103] # printf '%s\n' "${v@Q}" ''\'''\''' [STEP 104] #

Re: Documentation issue

2017-10-26 Thread Clark Wang
On Fri, Oct 27, 2017 at 1:17 PM, Eli Barzilay wrote: > > I already said why `unset` is different. If it wasn't clear, a direct > example is the fact that `delete` in javascript is a special syntax > rather than a function. To make it more confusing, the other obvious > place where an lvalue app

Re: Documentation issue

2017-10-26 Thread Clark Wang
On Fri, Oct 27, 2017 at 3:00 AM, Eli Barzilay wrote: > On Thu, Oct 26, 2017 at 2:02 PM, Chet Ramey wrote: > > > > It's more of a general statement about arrays, though it appears in > > the paragraph that discusses unset, so it's in the man page section on > > arrays. You have to be careful abo

man page: minor problem regarding ${parameter@operator}

2017-10-10 Thread Clark Wang
See: ${parameter@operator} Parameter transformation. The expansion is either a transforma- tion of the value of parameter or information about parameter itself, depending on the value of operator. Each operator is a single letter:

Re: A background ssh can take over the tty from bash?

2017-06-12 Thread Clark Wang
On Tue, Jun 13, 2017 at 11:00 AM, L A Walsh wrote: > >In this case you need to use "-n" with "-f" OR not use > either if you wish it to be suspended. > I did want the `ssh -o ControlMaster=yes` to run as a daemon. >If I launch ssh without "-f" but put it in background, it doesn't > gra

Re: A background ssh can take over the tty from bash?

2017-06-12 Thread Clark Wang
On Tue, Jun 13, 2017 at 2:48 AM, L A Walsh wrote: > Clark Wang wrote: > >> >> I've checked the ssh process and it does not catch SIGTTIN and that's why >> I'm confused. >> >> > >From what I understand, a background process will au

Re: A background ssh can take over the tty from bash?

2017-06-12 Thread Clark Wang
On Mon, Jun 12, 2017 at 10:48 PM, Chet Ramey wrote: > > > > This has come up before. You need to use `ssh -n' to avoid it > reading from > > stdin. Processes can ignore SIGTTIN, and ssh does so to avoid being > stopped > > if it reads from the tty while in the background. > > > > > >

Re: A background ssh can take over the tty from bash?

2017-06-11 Thread Clark Wang
On Mon, Jun 12, 2017 at 5:48 AM, Chet Ramey wrote: > On 6/10/17 10:19 AM, Clark Wang wrote: > > > If I kill the "ssh -o ControlMaster=no -o ControlPath=/tmp/socket.tmp > > 127.0.0.1 sleep " then tty #1 (pts/11) would be able to accept my > input > > agai

Re: A background ssh can take over the tty from bash?

2017-06-10 Thread Clark Wang
On Sat, Jun 10, 2017 at 11:00 PM, John McKown wrote: > On Sat, Jun 10, 2017 at 9:19 AM, Clark Wang wrote: > >> (I'm using bash 4.4.12 on Debian 8) >> >> Please follow the following steps to reproduce. >> >> From tty #1: >> >> $ tty >&g

A background ssh can take over the tty from bash?

2017-06-10 Thread Clark Wang
(I'm using bash 4.4.12 on Debian 8) Please follow the following steps to reproduce. >From tty #1: $ tty /dev/pts/11 $ ssh -o ControlMaster=yes -o ControlPath=/tmp/socket.tmp -N -f 127.0.0.1 root@127.0.0.1's password: $ ps -C ssh uw USER PID %CPU %MEMVSZ RSS TTY STAT START TIME

``shopt -s extglob'' and ``function @() { true; }''

2017-03-30 Thread Clark Wang
There is a post on stackoverflow: http://stackoverflow.com/questions/43117707/bashs-strange-behavior-on-a-function-named/ The *problem*: bash-4.4# shopt -s extglob bash-4.4# function @() { echo foo; } bash-4.4# @() foo bash-4.4# declare -f @() () { echo foo } bash-4.4# bash-4.4# unset -f '@()

Re: echo -n

2017-02-05 Thread Clark Wang
On Mon, Feb 6, 2017 at 12:15 PM, Jyoti B Tenginakai wrote: Thanks you all, > > Again I see that this printf we can use. But there are some scenarios > where the o/p does not exactly match with echo. So still its good to have a > way to pirnt -n /-e/-E with echo. Can this be considered as bug and

Re: Strange bash behavior

2016-12-02 Thread Clark Wang
On Fri, Dec 2, 2016 at 6:34 PM, Vladimir Marek wrote: > Nice analysis, does the second example look similar? > > bash -c 'bash -i 1; read -t 2 a < /dev/tty' > I think it's the same problem. After "bash -i" exited, "bash -c" is not the controlling process any more so it cannot read from the tty.

Re: Strange bash behavior

2016-12-02 Thread Clark Wang
On Fri, Dec 2, 2016 at 12:59 PM, Clark Wang wrote: > On Fri, Dec 2, 2016 at 6:28 AM, Vladimir Marek > wrote: > >> Hi, >> >> I'm not sure what is going on, but the bash test suite was getting >> stopped (as if SIGSTOP was received) in the middle. Trying t

Re: Strange bash behavior

2016-12-01 Thread Clark Wang
On Fri, Dec 2, 2016 at 6:28 AM, Vladimir Marek wrote: > Hi, > > I'm not sure what is going on, but the bash test suite was getting > stopped (as if SIGSTOP was received) in the middle. Trying to find > minimal set of conditions it came to this: > > - my ~/.bashrc has to contain 'cd /' (any dir w

Re: ``read -N n -t timeout'' saves partial input only when EOF is seen?

2016-11-24 Thread Clark Wang
On Fri, Nov 25, 2016 at 7:05 AM, L A Walsh wrote: > > > isabella parakiss wrote: > >> that's not true https://gist.github.com/fa4efd90376ff2714901e4429fdee734 >> read successfully reads the data, but then it's discarded by bash >> >> > >It's discarded by bash because the read doesn't rea

``read -N n'' removes leading "\n"s

2016-11-24 Thread Clark Wang
See following example: [STEP 100] # echo $BASH_VERSION 4.4.5(2)-release [STEP 101] # read -N 5 v abcd [STEP 102] # printf '%q\n' "$v" $'abcd\n' [STEP 103] # read -N 5 v abc[STEP 104] # printf '%q\n' "$v" abc [STEP 105] # The second read did not return the leading "\n"s. According to the manual

``read -N n -t timeout'' saves partial input only when EOF is seen?

2016-11-23 Thread Clark Wang
See following example: # echo $BASH_VERSION 4.4.5(2)-release # ( printf 12345 ) | ( read -t 1 -N 10 v; echo "<$v>" ) <12345> # ( printf 12345; sleep 2 ) | ( read -t 1 -N 10 v; echo "<$v>" ) <> # The second "read" did not save "12345" to "v". Is this a bug? -clark

Re: bind -m vi-insert '"jj": "\e"' problem in 4.4

2016-11-10 Thread Clark Wang
On Fri, Nov 4, 2016 at 6:36 PM, Clark Wang wrote: > For example, in vi-insert mode I input following in the command line: > > # foo abc > > The cursor is right after 'c'. Now if I press ESC then it'll go to > vi-command mode and the cursor will move to under &#

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'

bind -m vi-insert '"jj": "\e"' problem in 4.4

2016-11-04 Thread Clark Wang
For example, in vi-insert mode I input following in the command line: # foo abc The cursor is right after 'c'. Now if I press ESC then it'll go to vi-command mode and the cursor will move to under 'c'. But if I press jj the cursor would be still after 'c' and if then I press h the cursor will ski

Re: Bash bug

2016-08-22 Thread Clark Wang
On Tue, Aug 23, 2016 at 2:34 AM, Weshakie Löwe wrote: > When storing the value of code executed in a subshell the return value is > always 0 if the variable is local. > > Code example: > > A(){ > local return_value="$(bash -c "exit 1")" > echo $? > } > > function A: returns 0 - even though obvi

[PATCH] `alias' reusable form breaks with alias NAMES starting with `-'

2015-12-09 Thread Mingye Wang (Arthur2e5)
Bash Version: 4.3 Patch Level: 42 Description: `alias' does not `--'-ize alias items with a name starting with a `-' when it is invoked to print aliases in the reusable form. This causes `invalid option' errors when trying to reuse these output. Steps to Reproduce: Run the following segment:

[POSIX] `a='a b'; export a=$a; echo $a` gives `a b` instead of `a`

2015-12-05 Thread Mingye Wang (Arthur2e5)
Bash Version: 4.3 Patch Level: 42 Release Status: Release Description: According to [POSIX.1], `export` is special builtin *command*. Therefore as a command, in `a='a b'; export a=$a; echo $a`, `$a` should get split into words `a` and `b`. However, `bash` takes this as `export 'a=a b'` and gi

RE: Bash crash

2015-10-23 Thread Kai Wang X
-Original Message- From: Piotr Grzybowski [mailto:narsil...@gmail.com] Sent: 2015年10月23日 15:34 To: Kai Wang X Cc: chet.ra...@case.edu; Aharon Robbins; bug-bash@gnu.org Subject: Re: Bash crash I would run the same script under gdb (in the similar manner as you examine the core in th

RE: Bash crash

2015-10-22 Thread Kai Wang X
Grzybowski [mailto:narsil...@gmail.com] Sent: 2015年10月23日 1:08 To: Kai Wang X Cc: chet.ra...@case.edu; Aharon Robbins; bug-bash@gnu.org Subject: Re: Bash crash do I understand correctly, that when you comment the line 187 the issue is not existent? cheers, pg On Thu, Oct 22, 2015 at 4:39 AM, Kai Wang X w

  1   2   3   >