Current-Users archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
Re: Fixing swap1_stop
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.
| 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.
| 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.)
kre
Home |
Main Index |
Thread Index |
Old Index