Current-Users archive

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

Re: Fixing swap1_stop



(I feel a bit like Errol Flynn in Against All Flags)

Robert Elz <kre%munnari.OZ.AU@localhost> wrote:
 |    Date:        Wed, 16 Aug 2017 22:25:40 -0400
 |    From:        "Ian D. Leroux" <idleroux%fastmail.fm@localhost>
 |    Message-ID:  <20170816222540.de4ac3150f5ec12713a91b8b%fastmail.fm@localhost>
 |
 || Ok, but in that case I think that traditional single-quoting is
 || actually more suitable.
 |
 |I disagree there.
 |
 || If we $'' the filenames, then we have to make
 || sure that the filename contains no C-type escapes
 |
 |Yes, any \'s in the name need to have a \ inserted before them.   That's
 |kind of trivial.
 |
 || To say nothing of
 || $'\uXXXX' letting you inject arbitrary text into the output.
 |
 |I'm not sure what the point of that is, you can put exactly the same
 |in a single quoted (traditional) string simply by typing it literally.
 |The \u forms (\u and \U) simply make it more convenient in many cases.

It is also unambiguous.

 || Whereas '' avoids all of that (except for an embedded single-quote
 || character,
 |
 |Yes, but then whatever reads it needs to be able to handle the quoting
 |of the ' (which is kind of weird, either ...'\''... or ...'"'"'...
 |for a single quote in the middle of a single quoted string, and also \
 |whatever
 |reads it needs to understand to read multiple lines in the case of
 |an embedded newline.

I want to extend this argument.  $'' is the only type of quoting
that has not yet settled in the standard, and therefore the only
remaining chance (it seems impossible that $"" enters as a new
type of quoting in the sense of quoting due to no. 1, bash) to get
a straight type of quoting in the shell.

I mean a type of quote which makes it possible to generate
a complete output with a single quoted sentence, regardless of the
necessities.  This is why i have added the \$ (and \${..})
extension to gain variable expansion (as in "" quotes) and will at
a later time implement \`{} (as in Plan9 rc; or \`..` as in "").
Not planned and documented thus reserved yet, but \$(..) is surely
a good alternative/extension too.  (And in the MUA i maintain.)

So with this i now can do real things with $'', just as i would do
in perl(1), for example: write an unambiguous quoted string from
a to z, regardless of whatever content there may be.

What is not yet implemented (in my MUA) is that Unicode graphems
that are formed by adjacent \u/\U sequences are understood as
such.  You know, this compartmentalization of current shell quotes
is poison, there are languages in the world which just do not work
out like that.  Some standards have learned over time, e.g., MIME
RFC 2047 has this "string1 =?LANG-SPEC?one-atomic-string2?=
string3" stuff but RFC 2231 splits the entire data in pieces and
only the first specifies a LANG-SPEC, for all of the data.

Thus i think $'' should be made world-aware by making it capable
to avoid this compartmentalization, because whereas shells could
take the final token and iconv(3) it, it seems unlikely they will
in, e.g., to take a nonsense example, 'Splash, ⥼'"'"$'\u1F420''.'
It would be much better to write $'Splash, ⥼\'\u1F420.' and get
away with it.

 || but shquote(3) already takes care of that case).
 |
 |Once sh handles $' '  I would expect that shquote(3) will be enhanced
 |to make use of it.   It makes sense, the results are better in the
 |hard cases, and in the simple ones the only difference is the '$' at
 |the start.
 |
 || And if we use your
 || suggestion for a parsing mechanism, then the (single-quoted) output
 || would get parsed following shell's normal argument-parsing quoting
 || conventions, so it should all work.
 |
 |Yes, it should, provided that it is only ever parsed that way.  Much
 |more difficult to take the output of mount -p and find out where I last
 |mounted $'/foo/bar\n/foo/baz' though, normally you'd want to just be able
 |to use grep to accomplish that.
 |
 || Following Christos' suggestion, the assignment statements are easy:
 || 
 || MY_MOUNTED_DEVICE=$(mount -F %d)
 |
 |Sure (not exactly that I don't think, as without some arg to mount, you'd
 |get all of them listed) - but that means a lot of extra code in mount to
 |parse and output the format string, that is adding flexibility that is not
 |really needed (better done in whatever is using the output which knows
 |what it needs, and how much work is worth expending to achieve it).  I'd
 |keep what is added to mount as simple as possible - one output format that
 |simply lists everything in a very rigid way.   Easy to code, hard to get
 |wrong, and small (remember, mount needs to fit in install media.)

--steffen
|
|Der Kragenbaer,                The moon bear,
|der holt sich munter           he cheerfully and one by one
|einen nach dem anderen runter  wa.ks himself off
|(By Robert Gernhardt)


Home | Main Index | Thread Index | Old Index