bug-bash
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Bash' code to store string of any characters containing pair of "" a


From: Robert Elz
Subject: Re: Bash' code to store string of any characters containing pair of "" and '' at once
Date: Sun, 22 Dec 2024 12:02:00 +0700

    Date:        Sun, 22 Dec 2024 13:45:19 +1000
    From:        Martin D Kealey <martin@kurahaupo.gen.nz>
    Message-ID:  
<CAN_U6MUa33ApoymR72NtHFuzei0GWpysVKj=n=Cu20rBRv4v3Q@mail.gmail.com>

  | 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 either.

Most likely he is trying to quote an unknown (in advance) string, so
nothing in it will be interpreted by the shell.   printf %q might be
a solution if that is the case (or better in a modern enough bash, %Q).

But once again, we have a user seeking assistance with solving a problem
they have decided they need to solve, in order to accomplish some other
goal, without indicating what they're trying to achieve.   We'd all be
better off simply refusing to answer questions like that - insist on
knowing the actual problem being solved, rather than some minor step
that the user has determined is important to deal with - when in most
cases if it truly is difficult (this one wasn't, rather there are just
so many possible answers that picking which requires more info) then
99% of the time the problem stated never needed solving at all.

kre




reply via email to

[Prev in Thread] Current Thread [Next in Thread]