Re: Bash' code to store string of any characters containing pair of "" and '' at once

2024-12-25 Thread Dale R. Worley
Greg Wooledge writes: >> You need to escape one of the types of quotes. Double quotes is >> generally simpler: >> >> $ x="foo \"foo\" and 'bar' content" >> $ echo "$x" >> foo "foo" and 'bar' content > > Only in this restricted case. Using double quotes as the outer layer > means you have to back

Re: Bash' code to store string of any characters containing pair of "" and '' at once

2024-12-23 Thread Chet Ramey
On 12/21/24 7:29 PM, Robert Elz wrote: I'm not sure of its origins (it was proposed to POSIX decades ago), Chet can confirm, but I suspect bash picked it up from the proposal to POSIX. It predated that. There was a group of shell implementors who got together to discuss possible POSIX extensio

Re: Bash' code to store string of any characters containing pair of "" and '' at once

2024-12-22 Thread Budi
👍 Budi reacted via Gmail On Sun, Dec 22, 2024 at 10:45 AM Martin D Kealey wrote: > > On Sun, 22 Dec 2024, 03:49 Budi, wrote: > >> How is Bash' code to store string of any charact

Re: Bash' code to store string of any characters containing pair of "" and '' at once

2024-12-22 Thread Andreas Schwab
On Dez 22 2024, Martin D Kealey wrote: > If you don't mind even more thinking then you can instead memorize the list > of characters that need \ and skip all the others; they are space, tab, > newline, and "#$'&<>*()?`\[]| Careful. \ has a different meaning. -- Andreas Schwab, sch...@linux-m68k

Re: Bash' code to store string of any characters containing pair of "" and '' at once

2024-12-21 Thread Robert Elz
Date:Sun, 22 Dec 2024 13:45:19 +1000 From:Martin D Kealey Message-ID: | But a nagging question is why does the text contain both ' and " | characters? My guess (and that is all it is) is that the answer isn't that it contains both, but that it might contain eit

Re: Bash' code to store string of any characters containing pair of "" and '' at once

2024-12-21 Thread Greg Wooledge
On Sun, Dec 22, 2024 at 13:45:19 +1000, Martin D Kealey wrote: > Failing that, by far the "simplest" approach to "literal" text is not to > have it inside the script, but in a separate file that the script can read. Yes, this. I omitted this case in my initial reply, thought of it later, but didn

Re: Bash' code to store string of any characters containing pair of "" and '' at once

2024-12-21 Thread Martin D Kealey
On Sun, 22 Dec 2024, 03:49 Budi, wrote: > How is Bash' code to store string of any characters should be containing > pair of "" and '' at the same time explicitly, being exact verbatim so, > ie. cannot be modified, escaped or etc, as expected from ordinary/naive > human writing), into a variable

Re: Bash' code to store string of any characters containing pair of "" and '' at once

2024-12-21 Thread Robert Elz
Date:Sun, 22 Dec 2024 09:39:11 +0700 From:Robert Elz Message-ID: <10875.1734835...@jacaranda.noi.kre.to> | Not sure about current bash I must has been bashed in the brain there, I meant dash, bash has had this for eons (as have most of the others in which it works,

Re: Bash' code to store string of any characters containing pair of "" and '' at once

2024-12-21 Thread Robert Elz
Date:Sat, 21 Dec 2024 19:47:31 -0500 From:Greg Wooledge Message-ID: <20241222004731.go29...@wooledge.org> | Either way, it's not widespread yet, and one shouldn't expect it to be | available outside of bash. If it were only in bash it would never have made it int

Re: Bash' code to store string of any characters containing pair of "" and '' at once

2024-12-21 Thread Greg Wooledge
On Sun, Dec 22, 2024 at 07:29:14 +0700, Robert Elz wrote: > Date:Sat, 21 Dec 2024 13:49:48 -0500 > From:Greg Wooledge > Message-ID: <20241221184948.gm29...@wooledge.org> > > | Choice #2: use $'...' quoting, > | Choice 2 is a bash extension. > > No it isn't, or at

Re: Bash' code to store string of any characters containing pair of "" and '' at once

2024-12-21 Thread Robert Elz
Date:Sat, 21 Dec 2024 13:49:48 -0500 From:Greg Wooledge Message-ID: <20241221184948.gm29...@wooledge.org> | Choice #2: use $'...' quoting, | Choice 2 is a bash extension. No it isn't, or at least not any more. Dollar-Quote quoting (sometimes called C-stye strin

Re: Bash' code to store string of any characters containing pair of "" and '' at once

2024-12-21 Thread Lawrence Velázquez
On Sat, Dec 21, 2024, at 1:52 PM, Greg Wooledge wrote: > On Sat, Dec 21, 2024 at 09:56:15 -0800, Eric Pruitt wrote: >> You need to escape one of the types of quotes. Double quotes is >> generally simpler: > > Only in this restricted case. Using double quotes as the outer layer > means you have to

Re: Bash' code to store string of any characters containing pair of "" and '' at once

2024-12-21 Thread Greg Wooledge
On Sat, Dec 21, 2024 at 09:56:15 -0800, Eric Pruitt wrote: > On Sun, Dec 22, 2024 at 12:49:07AM +0700, Budi wrote: > > How is Bash' code to store string of any characters should be containing > > pair of "" and '' at the same time explicitly, being exact verbatim so, > > ie. cannot be modified, esc

Re: Bash' code to store string of any characters containing pair of "" and '' at once

2024-12-21 Thread Greg Wooledge
On Sun, Dec 22, 2024 at 00:49:07 +0700, Budi wrote: > How is Bash' code to store string of any characters should be containing > pair of "" and '' at the same time explicitly, being exact verbatim I'm interpreting this as: * You would like to store some data in a string variable. * The data is

Re: Bash' code to store string of any characters containing pair of "" and '' at once

2024-12-21 Thread Eric Pruitt
On Sun, Dec 22, 2024 at 12:49:07AM +0700, Budi wrote: > How is Bash' code to store string of any characters should be containing > pair of "" and '' at the same time explicitly, being exact verbatim so, > ie. cannot be modified, escaped or etc, as expected from ordinary/naive > human writing), into

Bash' code to store string of any characters containing pair of "" and '' at once

2024-12-21 Thread Budi
How is Bash' code to store string of any characters should be containing pair of "" and '' at the same time explicitly, being exact verbatim so, ie. cannot be modified, escaped or etc, as expected from ordinary/naive human writing), into a variable let, eg., it be *foo "foo" and 'bar' content* v=