Bram Moolenaar wrote:
[...]
> It appears it all works fine when 'shell' is "sh", but not when it is
> "bash". What is the difference between "sh" and "bash" considering
> single quotes?
>
I'll try to find out, and the manpage for bash (which also describes how bash
reacts when invoked as sh) is extremely long. I'm getting the info below from
the QUOTING section.
On my system, /usr/bin/sh is a softlink for /bin/bash but "man sh" gives the
manpage for ash.
If Vim escapes the apostrophe in filenames in Session.vim (as created by
:mksession) when the shell is sh but not when it is bash, I suspect the error
is in Vim. Those lines are for Vim (not *sh) consumption after all. (This
means that filenames containing apostrophes will be lost from the buffer list
after ":mks!" followed by ":qa" and "vim -S".)
From both "man bash" and "man sh", single quotes preserve the literal value
of the enclosed string. A single-quoted string cannot itself contain a single
quote, even when preceded by a backslash.
Outside quotes, a backslash preserves the value of the following char, except
that an end-of-line backslash means continuation to the next line.
Bash (but apparently not sh) treats $'string' specially: that is expanded
according to the ANSI C standard, with the following escapes treated specially:
\a alert (bell)
\b backspace
\e escape
\f form feed
\n new line
\r carriage return
\t horizontal tab
\v vertical tab
\\ backslash
\' single quote
\nnn octal byte
\xHH hex byte
\cx Control-x (where x is anything that can take a Ctrl modifier)
The expanded result is given with single quotes.
$"string" (still in bash) is translated according to the current locale; if
that locale is C or POSIX the $ is ignored. The expanded result is
double-quoted.
In double quoted strings, only $ (dollar) ` (backtick) " (double quote),
<newline> and \ (backslash) are special. The backslash is used there to give
them back their literal value. In bash but not sh, ! is special only if
history expansion is enabled.
Best regards,
Tony.
--
Waste not, get your budget cut next year.
--~--~---------~--~----~------------~-------~--~----~
You received this message from the "vim_dev" maillist.
For more information, visit http://www.vim.org/maillist.php
-~----------~----~----~----~------~----~------~--~---