[Boards: 3 / a / aco / adv / an / asp / b / bant / biz / c / can / cgl / ck / cm / co / cock / d / diy / e / fa / fap / fit / fitlit / g / gd / gif / h / hc / his / hm / hr / i / ic / int / jp / k / lgbt / lit / m / mlp / mlpol / mo / mtv / mu / n / news / o / out / outsoc / p / po / pol / qa / qst / r / r9k / s / s4s / sci / soc / sp / spa / t / tg / toy / trash / trv / tv / u / v / vg / vint / vip / vp / vr / w / wg / wsg / wsr / x / y ] [Search | Free Show | Home]

bash

This is a blue board which means that it's for everybody (Safe For Work content only). If you see any adult content, please report it.

Thread replies: 7
Thread images: 2

File: 1392705925897.gif (966KB, 500x281px) Image search: [Google]
1392705925897.gif
966KB, 500x281px
/g/, when double quoting, why does bash not remove the backslash when escaping an exclamation mark?

Why does
"Hi\!"
expand to
Hi\!
and not
Hi!
???

history? just to fuck with people? gentoo?
>>
Also, are there better alternatives to bash? It seems like the best standard shell, but honestly the syntax is kinda shit.
>>
>>55775182
\ is used to include things.
for example if a path would have a space in a folder youd use \ to include the spaces to properly display it.
modern terminal emulators hide this from you though.
>>
File: ojimages.jpg (7KB, 280x180px) Image search: [Google]
ojimages.jpg
7KB, 280x180px
>>55775240
I think you don't understand my question. Here's an excerpt from the manual:

Enclosing characters in double quotes (‘"’) preserves the literal value of all characters within the quotes, with the exception of ‘$’, ‘`’, ‘\’, and, when history expansion is enabled, ‘!’. The characters ‘$’ and ‘`’ retain their special meaning within double quotes (see Shell Expansions). The backslash retains its special meaning only when followed by one of the following characters: ‘$’, ‘`’, ‘"’, ‘\’, or newline. Within double quotes, backslashes that are followed by one of these characters are removed. Backslashes preceding characters without a special meaning are left unmodified. A double quote may be quoted within double quotes by preceding it with a backslash. If enabled, history expansion will be performed unless an ‘!’ appearing in double quotes is escaped using a backslash. The backslash preceding the ‘!’ is not removed.

It's that last sentence that makes no sense.

For instance:
"Hi\"" => Hi"
while:
"Hi!-1" => touch self.txt
and:
"Hi\!-1" => Hi\!-1

It's really weird that it chooses to leave that backslash in there ONLY for !. Is this completely arbitrary? Is it to prevent interference with some other mechanism? Is it for historical raisins?
>>
>GNU bash
>>
I will be monitoring this thread, if not for the answer then at least because I like the way this /g/man talks.

Good eye for detail too.
>>
>>55775182
History expansion is on?
Thread posts: 7
Thread images: 2


[Boards: 3 / a / aco / adv / an / asp / b / bant / biz / c / can / cgl / ck / cm / co / cock / d / diy / e / fa / fap / fit / fitlit / g / gd / gif / h / hc / his / hm / hr / i / ic / int / jp / k / lgbt / lit / m / mlp / mlpol / mo / mtv / mu / n / news / o / out / outsoc / p / po / pol / qa / qst / r / r9k / s / s4s / sci / soc / sp / spa / t / tg / toy / trash / trv / tv / u / v / vg / vint / vip / vp / vr / w / wg / wsg / wsr / x / y] [Search | Top | Home]

I'm aware that Imgur.com will stop allowing adult images since 15th of May. I'm taking actions to backup as much data as possible.
Read more on this topic here - https://archived.moe/talk/thread/1694/


If you need a post removed click on it's [Report] button and follow the instruction.
DMCA Content Takedown via dmca.com
All images are hosted on imgur.com.
If you like this website please support us by donating with Bitcoins at 16mKtbZiwW52BLkibtCr8jUg2KVUMTxVQ5
All trademarks and copyrights on this page are owned by their respective parties.
Images uploaded are the responsibility of the Poster. Comments are owned by the Poster.
This is a 4chan archive - all of the content originated from that site.
This means that RandomArchive shows their content, archived.
If you need information for a Poster - contact them.