${p+\"$p\"}

2019-01-21 Thread Dan Jacobson
So how am I to get "A" with bash? $ cat z p=A cat <

Re: [bug-bash] $RANDOM not Cryptographically secure pseudorandom number generator

2019-01-21 Thread Greg Wooledge
On Sun, Jan 20, 2019 at 03:39:45PM +0100, Martijn Dekker wrote: > E.g. to create a random character string for a temporary > file name, you could do > > filename_suffix() { > chars=ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789 > length=${#chars} > for ((i=0; i<10; i++)

Re: "return" should not continue script execution, even if used inappropriately

2019-01-21 Thread Greg Wooledge
On Sun, Jan 20, 2019 at 05:43:04PM -0800, don fong wrote: > i don't see how this helps. the point is to have one file of code that > behaves differently depending on whether it's dotted in or executed at the > top level. https://mywiki.wooledge.org/BashFAQ/109

Re: ${p+\"$p\"}

2019-01-21 Thread Greg Wooledge
On Mon, Jan 21, 2019 at 09:14:26PM +0800, Dan Jacobson wrote: > So how am I to get > "A" > with bash? > > $ cat z > p=A > cat < ${p+\"$p\"} > ${p+"$p"} > EOF > $ bash z > \"A\" > A > $ dash z > "A" <=WANT THIS > A > $ bash --version > GNU bash, version 5.0.0(1)-release... So, if I'm readi

Re: bug: illegal function name?

2019-01-21 Thread Andrey Butirsky
On 21.01.2019 05:26, Robert Elz wrote: > I think his point is that if unset "unset f" (no flags) works to unset > function f, if f is not a (set) variable, then it should work every time > "f" is not a set variable, not only the times when the word "f" happens > to be of the correct syntax to be a

Re: ${p+\"$p\"}

2019-01-21 Thread Chet Ramey
On 1/21/19 8:14 AM, Dan Jacobson wrote: > So how am I to get > "A" > with bash? echo ${p+\"$p\"} > $ cat z > p=A > cat < ${p+\"$p\"} > ${p+"$p"} > EOF > $ bash z > \"A\" > A It's the here-document. Backslashes and double quotes in here documents are kind of strange. This is historical sh behavi

Re: [bug-bash] $RANDOM not Cryptographically secure pseudorandom number generator

2019-01-21 Thread Chet Ramey
On 1/21/19 8:48 AM, Greg Wooledge wrote: > On Sun, Jan 20, 2019 at 03:39:45PM +0100, Martijn Dekker wrote: >> E.g. to create a random character string for a temporary >> file name, you could do >> >> filename_suffix() { >> chars=ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789 >>

Re: [bug-bash] $RANDOM not Cryptographically secure pseudorandom number generator

2019-01-21 Thread Robert Elz
Date:Mon, 21 Jan 2019 09:43:17 -0500 From:Chet Ramey Message-ID: <94f6225c-8de2-cd3d-c83e-0d061c8b0...@case.edu> | Take the linux mktemp, add the -c option, Please don't, or at least not the -c option (I don't care if mktemp is made into a builtin, seems unnecessar

Re: ${p+\"$p\"}

2019-01-21 Thread Robert Elz
Date:Mon, 21 Jan 2019 09:37:02 -0500 From:Chet Ramey Message-ID: | It's the here-document. Backslashes and double quotes in here documents are | kind of strange. This is historical sh behavior. Not so much backslashes, a here doc (this form) is just a double quo

Re: [bug-bash] $RANDOM not Cryptographically secure pseudorandom number generator

2019-01-21 Thread Chet Ramey
On 1/20/19 9:04 PM, Rawiri Blundell wrote: > On Mon, Jan 21, 2019 at 10:54 AM Chet Ramey wrote: >> >> On 1/20/19 7:52 AM, Rawiri Blundell wrote: >> >>> So it might be a case of restricting the usability of this change to >>> newer kernels that have dedicated calls like getrandom() or >>> getentrop

Re: bug: illegal function name?

2019-01-21 Thread Chet Ramey
On 1/20/19 10:56 PM, pepa65 wrote: > On 20/1/2019 19:50, Eduardo A. Bustamante López wrote: >> Changing the behavior of `unset f' to only ever unset variables means >> potentially breaking existing scripts. Is the inconsistency reported severe >> enough to make this change? > > The alternative wou

Re: "return" should not continue script execution, even if used inappropriately

2019-01-21 Thread Bize Ma
-- *From*: Greg Wooledge *Subject*: Re: "return" should not continue script execution, even if used inappropriately *Date*: Mon, 21 Jan 2019 09:01:33 -0500 -- On Sun, Jan 20, 2019 at 05:43:04PM -0800, don fong wrote: >* i don't see how this h

Re: ${p+\"$p\"}

2019-01-21 Thread Chet Ramey
On 1/21/19 11:38 AM, Robert Elz wrote: > Date:Mon, 21 Jan 2019 09:37:02 -0500 > From:Chet Ramey > Message-ID: > > | It's the here-document. Backslashes and double quotes in here documents > are > | kind of strange. This is historical sh behavior. > > Not so muc

Re: ${p+\"$p\"}

2019-01-21 Thread don fong
here is another possible workaround, apologies if this has already been mentioned. cat < wrote: > On Mon, Jan 21, 2019 at 09:14:26PM +0800, Dan Jacobson wrote: > > So how am I to get > > "A" > > with bash? > > > > $ cat z > > p=A > > cat < > ${p+\"$p\"} > > ${p+"$p"} > > EOF > > $ bash z > > \"A\

Re: ${p+\"$p\"}

2019-01-21 Thread Bize Ma
*From*: Dan Jacobson *Subject*: ${p+\"$p\"} *Date*: Mon, 21 Jan 2019 21:14:26 +0800 -- So how am I to get "A" with bash? How about: #!/bin/bash p=A q='"' cat <<_EOF_ ${p+$q$p$q} _EOF_ Works on all shells I tested it.

Re: "return" should not continue script execution, even if used inappropriately

2019-01-21 Thread don fong
Greg Wooledge, and Bize Ma, thanks. to be clear, i wasn't asking "how to do it", i was just trying to explain why the supposedly "crazy" or "weird" python convention makes a lot of sense even in the bash context. addressing this from the FAQ: "Bash can do this, but it's not a natural style, and y

Re: [bug-bash] $RANDOM not Cryptographically secure pseudorandom number generator

2019-01-21 Thread Martijn Dekker
Op 21-01-19 om 20:12 schreef Chet Ramey: > On 1/20/19 9:04 PM, Rawiri Blundell wrote: >> For what it's worth I did consider suggesting URANDOM, however I >> figured some users may confuse it like this: >> >> RANDOM -> /dev/random >> URANDOM -> /dev/urandom >> >> Couple that with an established base

Re: ${p+\"$p\"}

2019-01-21 Thread Bize Ma
-- *From*: Robert Elz *Subject*: Re: ${p+\"$p\"} *Date*: Mon, 21 Jan 2019 23:38:22 +0700 -- (...) > With the quotes, most other shells produce the output reported > from dash (that includes ksh93, yash, ...) zsh just says it iis > a parse e

Re: [bug-bash] $RANDOM not Cryptographically secure pseudorandom number generator

2019-01-21 Thread Quentin
On January 20, 2019 2:39:45 PM UTC, Martijn Dekker wrote: >filename_suffix() { > chars=ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789 >length=${#chars} >for ((i=0; i<10; i++)) do >printf '%s' "${chars:$(( SECURE_RANDOM % length + 1 )):1}" >done >} The char

Re: [bug-bash] $RANDOM not Cryptographically secure pseudorandom number generator

2019-01-21 Thread Chet Ramey
On 1/21/19 4:46 PM, Martijn Dekker wrote: > So I think SRANDOM is the best name (or SECURE_RANDOM, though that is a > bit long). I'm OK with SRANDOM. -- ``The lyf so short, the craft so long to lerne.'' - Chaucer ``Ars longa, vita brevis'' - Hippocrates Chet Ramey, UTech, CWRU

loadable cat bug?

2019-01-21 Thread Peng Yu
When I use the loadable cat, I may get the following error. The input is a fifo in this specific case. cat: cannot open /tmp/tmp.VXkbqFlPtH: Interrupted system call So far, I can not make a minimal script to demonstrate the problem. But if I replace it with coreutils cat in my code, the problem i

Where is GLOBAL_COMMAND?

2019-01-21 Thread Peng Yu
Hi, GLOBAL_COMMAND is mentioned as a global variable. But I don't find it. Is it renamed to something else? eval.c 276-/* Call the YACC-generated parser and return the status of the parse. 277- Input is read from the current input stream (bash_input). yyparse 278: leaves the parsed command i

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 ()