Re: RFE: new syntax for command substitution to keep trailing newlines?
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 ...)
Re: RFE: new syntax for command substitution to keep trailing newlines?
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 >> > > Or keep it similar to $(cmd), like: > > $(& cmd ...) > $(; cmd ...) > $(| cmd ...) > $(|cmd ...) makes more sense for me. '|' is a pipe which means passthrough. For future extensions, use $(&flag1[=value1]&flag2[=value2] cmd ...) For example, $(&keep_trailing_newlines cmd ...) is just the same as $(|cmd ...). $(&no_fork cmd ...) means the ksh style ${ cmd ... }.
Re: . and .. are included where they were excluded before
On 27/01/2021 14.49, k...@plushkava.net wrote: > That's why your .? glob doesn't match the .. pathname. Normally, > GLOBIGNORE isn't set. After unsetting GLOBIGNORE: $ declare -p GLOBIGNORE declare -x GLOBIGNORE="" $ shopt -u extglob $ echo @(?|.?) -bash: syntax error near unexpected token `(' $ shopt -s extglob $ echo @(?|.?) . .. At any rate, the following command may help you to track > down where it's coming from. > > $ PS4='+$BASH_SOURCE:$LINENO: ' bash -ixlc '' |& less It turned out this was erroneously set in a profile... Thanks, Peter
Re: RFE: new syntax for command substitution to keep trailing newlines?
On 27/01/2021 16.07, Clark Wang wrote: > $(|cmd ...) makes more sense for me. '|' is a pipe which means passthrough. > > For future extensions, use > > $(&flag1[=value1]&flag2[=value2] cmd ...) > > For example, > > $(&keep_trailing_newlines cmd ...) is just the same as $(|cmd ...). > $(&no_fork cmd ...) means the ksh style ${ cmd ... }. But piping basically connects subshells, and the semantics was supposed to be "no subshell". Why then not this: $(; var1=val2 var2=val2 command;) Because a semicolon normally does not start a subshell, and "$(; ;)" is more or less a clean and meaningful delimiter. Although it still has the ( ) parentheses which indicate a subshell... ${; var1=val2 var2=val2 command;} (Confusing for using the "${ }" variable substitution semantics...) "${{ }}" is then not so bad an option, duplication of brackets to change/enhance the semantics is already a thing in bash. Peter
Re: . and .. are included where they were excluded before
On 1/27/21 4:07 AM, pepa65 wrote: On 27/01/2021 14.49, k...@plushkava.net wrote: That's why your .? glob doesn't match the .. pathname. Normally, GLOBIGNORE isn't set. After unsetting GLOBIGNORE: That doesn't unset GLOBIGNORE. $ declare -p GLOBIGNORE declare -x GLOBIGNORE="" Depending on your environment, this may leave the dotglob option enabled. -- ``The lyf so short, the craft so long to lerne.'' - Chaucer ``Ars longa, vita brevis'' - Hippocrates Chet Ramey, UTech, CWRUc...@case.eduhttp://tiswww.cwru.edu/~chet/
Re: RFE: new syntax for command substitution to keep trailing newlines?
On 1/27/21 12:08 AM, Oğuz wrote: What's wrong with printing an `x' at the end and removing it later? Nothing. -- ``The lyf so short, the craft so long to lerne.'' - Chaucer ``Ars longa, vita brevis'' - Hippocrates Chet Ramey, UTech, CWRUc...@case.eduhttp://tiswww.cwru.edu/~chet/
Re: RFE: new syntax for command substitution to keep trailing newlines?
as well as one newline instead of x, it cuts afik _one_ ending nrwline, not all On Wed, Jan 27, 2021, 21:01 Chet Ramey wrote: > On 1/27/21 12:08 AM, Oğuz wrote: > > What's wrong with printing an `x' at the end and removing it later? > > Nothing. > > -- > ``The lyf so short, the craft so long to lerne.'' - Chaucer > ``Ars longa, vita brevis'' - Hippocrates > Chet Ramey, UTech, CWRUc...@case.eduhttp://tiswww.cwru.edu/~chet/ > >
Re: RFE: new syntax for command substitution to keep trailing newlines?
On Wed, Jan 27, 2021 at 09:21:09PM +0100, Alex fxmbsw7 Ratchev wrote: > as well as one newline instead of x, it cuts afik _one_ ending nrwline, not > all If you mean command substitution, this is incorrect. Command substitution removes all trailing newlines.
Re: RFE: new syntax for command substitution to keep trailing newlines?
On 1/27/21 3:21 PM, Alex fxmbsw7 Ratchev wrote: as well as one newline instead of x, it cuts afik _one_ ending nrwline, not all No, command substitution removes all trailing newlines. -- ``The lyf so short, the craft so long to lerne.'' - Chaucer ``Ars longa, vita brevis'' - Hippocrates Chet Ramey, UTech, CWRUc...@case.eduhttp://tiswww.cwru.edu/~chet/
Re: RFE: new syntax for command substitution to keep trailing newlines?
Le 27/01/2021 à 21:21, Alex fxmbsw7 Ratchev écrivait : as well as one newline instead of x, it cuts afik _one_ ending nrwline, not all It removes every trailing newline a=$(printf $'hello\n\n\n'); declare -p a Now if you want to preserve all the newlines you can use an ASCII EOF character (formerly Ctrl + Z) that is unlikely to be part of a legit string: a=$(printf $'hello\n\n\n\32'); a=${a%$'\32'}; declare -p a -- Léa Gris
Re: RFE: new syntax for command substitution to keep trailing newlines?
On 1/27/21 3:29 PM, Léa Gris wrote: Now if you want to preserve all the newlines you can use an ASCII EOF character (formerly Ctrl + Z) that is unlikely to be part of a legit string: a=$(printf $'hello\n\n\n\32'); a=${a%$'\32'}; declare -p a It doesn't matter what you use (besides a newline, of course). Just remove a single character: a=${a%?}. -- ``The lyf so short, the craft so long to lerne.'' - Chaucer ``Ars longa, vita brevis'' - Hippocrates Chet Ramey, UTech, CWRUc...@case.eduhttp://tiswww.cwru.edu/~chet/
Re: RFE: new syntax for command substitution to keep trailing newlines?
hm had it wrong memorized, maybe i was working with a space instead of x there i sadly left all computer stuff since you didnt fix the three four major bugs i posted, since those stopped my coding wantings to 100% :( however i have a repost of em ( no code isolationed cases since i only know the bugs when my comolete codes are ) to remind you to fix em, so i can be happy again peace On Wed, Jan 27, 2021, 21:27 Chet Ramey wrote: > On 1/27/21 3:21 PM, Alex fxmbsw7 Ratchev wrote: > > as well as one newline instead of x, it cuts afik _one_ ending nrwline, > not all > > No, command substitution removes all trailing newlines. > > -- > ``The lyf so short, the craft so long to lerne.'' - Chaucer > ``Ars longa, vita brevis'' - Hippocrates > Chet Ramey, UTech, CWRUc...@case.eduhttp://tiswww.cwru.edu/~chet/ >
Re: RFE: new syntax for command substitution to keep trailing newlines?
On 1/27/21 3:37 PM, Alex fxmbsw7 Ratchev wrote: hm had it wrong memorized, maybe i was working with a space instead of x there i sadly left all computer stuff since you didnt fix the three four major bugs i posted, since those stopped my coding wantings to 100% :( however i have a repost of em ( no code isolationed cases since i only know the bugs when my comolete codes are ) to remind you to fix em, so i can be happy again If you mean https://lists.gnu.org/archive/html/bug-bash/2020-11/msg00064.html there is a fix in the devel branch tagged for bash-5.2. If you mean https://lists.gnu.org/archive/html/bug-bash/2020-11/msg00106.html that's the same bug. But go on, king. -- ``The lyf so short, the craft so long to lerne.'' - Chaucer ``Ars longa, vita brevis'' - Hippocrates Chet Ramey, UTech, CWRUc...@case.eduhttp://tiswww.cwru.edu/~chet/
Re: RFE: new syntax for command substitution to keep trailing newlines?
thank you big time sir can you handle me the git cmd to get the sources with the fixes ? :)) /good night and thank you big time for your kind friendlyness On Wed, Jan 27, 2021, 22:01 Chet Ramey wrote: > On 1/27/21 3:37 PM, Alex fxmbsw7 Ratchev wrote: > > hm had it wrong memorized, maybe i was working with a space instead of x > there > > i sadly left all computer stuff since you didnt fix the three four major > > bugs i posted, since those stopped my coding wantings to 100% :( > > > > however i have a repost of em ( no code isolationed cases since i only > know > > the bugs when my comolete codes are ) to remind you to fix em, so i can > be > > happy again > > If you mean > > https://lists.gnu.org/archive/html/bug-bash/2020-11/msg00064.html > > there is a fix in the devel branch tagged for bash-5.2. > > If you mean > > https://lists.gnu.org/archive/html/bug-bash/2020-11/msg00106.html > > that's the same bug. > > But go on, king. > > -- > ``The lyf so short, the craft so long to lerne.'' - Chaucer > ``Ars longa, vita brevis'' - Hippocrates > Chet Ramey, UTech, CWRUc...@case.eduhttp://tiswww.cwru.edu/~chet/ >
Re: RFE: new syntax for command substitution to keep trailing newlines?
On 1/27/21 4:07 PM, Alex fxmbsw7 Ratchev wrote: thank you big time sir can you handle me the git cmd to get the sources with the fixes ? :)) Just fetch the devel branch. git clone --branch devel git://git.savannah.gnu.org/bash.git will probably work. You have to uncomment the fix. Search for your name. -- ``The lyf so short, the craft so long to lerne.'' - Chaucer ``Ars longa, vita brevis'' - Hippocrates Chet Ramey, UTech, CWRUc...@case.eduhttp://tiswww.cwru.edu/~chet/
Re: RFE: new syntax for command substitution to keep trailing newlines?
On 28/01/2021 03.29, Léa Gris wrote: > Now if you want to preserve all the newlines you can use an ASCII EOF > character (formerly Ctrl + Z) that is unlikely to be part of a legit > string: > > a=$(printf $'hello\n\n\n\32'); a=${a%$'\32'}; declare -p a When doing this there is no subshell involved so newlines are preserved: printf -v a $'hello\n\n\n' (I guess that wasn't your point...) Peter