escaping

What are the differences in echo between zsh and bash?

风流意气都作罢 提交于 2021-01-28 10:50:51
问题 In bash, in this specific case, echo behaves like so: $ bash -c 'echo "a\nb"' a\nb but in zsh the same thing turns out very differently...: $ zsh -c 'echo "a\nb"' a b and fwiw in fish, because I was curious: $ fish -c 'echo "a\nb"' a\nb I did realize that I can run: $ zsh -c 'echo -E "a\nb"' a\nb But now I am worried that I'm about to stumble into more gotchas on such a basic operation. (Thus my investigation into fish: if I'm going to have to make changes at such a low level for zsh, why not

What are the differences in echo between zsh and bash?

余生长醉 提交于 2021-01-28 10:50:46
问题 In bash, in this specific case, echo behaves like so: $ bash -c 'echo "a\nb"' a\nb but in zsh the same thing turns out very differently...: $ zsh -c 'echo "a\nb"' a b and fwiw in fish, because I was curious: $ fish -c 'echo "a\nb"' a\nb I did realize that I can run: $ zsh -c 'echo -E "a\nb"' a\nb But now I am worried that I'm about to stumble into more gotchas on such a basic operation. (Thus my investigation into fish: if I'm going to have to make changes at such a low level for zsh, why not

Use string variable as Applescript command argument

陌路散爱 提交于 2021-01-28 07:25:00
问题 I'm trying to do the following: on cleanup(x) tell application "Finder" clean up window 1 by x end tell end cleanup cleanup("name") However since x variable is a string, the clean up command doesn't accept it and exits with error. Is there a way to convert the string to something that the commands accepts or some other solution to unquote the variable without using if, else statements like this: on cleanup(x) tell application "Finder" if x is "name" then clean up window 1 by name end if end

Clean method for storing regex strings in python

你离开我真会死。 提交于 2021-01-28 04:40:02
问题 I want to store a series of pre-tested regexes in a config file, and read and apply them at runtime. However, because they're commonly packed with escape characters, by the time I've loaded them up into memory, and populated them into a dict, they've been escaped to death. How can I preserve the integrity of my regex definitions, so that they will re.compile ? Alternately, given that many of the post-escape strings end up in a form with \x00 characters, how do I convert these back into a form

Is this deep obfuscation? Cannot understand the meaning of it

帅比萌擦擦* 提交于 2021-01-27 23:12:16
问题 Given the following script: É = -~-~[], ó = -~É, Ë = É << É, þ = Ë + ~[]; Ì = (ó - ó)[Û = ('' + {})[É + ó] + ('' + {})[ó - É] + ([].ó + '')[ó - É] + (!!'' + '')[ó] + ({} + '')[ó + ó] + (!'' + '')[ó - É] + (!'' + '')[É] + ('' + {})[É + ó] + ({} + '')[ó + ó] + ('' + {})[ó - É] + (!'' + '')[ó - É]][Û]; Ì(Ì((!'' + '')[ó - É] + (!'' + '')[ó] + (!'' + '')[ó - ó] + (!'' + '')[É] + ((!'' + ''))[ó - É] + ([].$ + '')[ó - É] + '\'' + '' + '\\' + (ó - É) + (É + É) + (ó - É) + '\\' + (þ) + (É + ó) + '\\'

Shell script and quote in path

淺唱寂寞╮ 提交于 2021-01-27 17:51:41
问题 I must be dense, but I simply cannot solve this. I have googled and searched here and nothing I find works. I have a simple shell script. Currently it looks as below. The diff command fails with "No such file or directory" on the second argument (the one in red below). #!/bin/bash set -x cd "/Volumes/$1/Backups.backupdb/SkiAddict’s Mac/Latest" time diff -qr /Users/n/Documents/Code "SkiAddict’s Mac/Users/n/Documents/Code" I call the script like this from the Terminal: bash myScript.sh Quadra I

Impossible to store json in python with single un-escaped backslash

醉酒当歌 提交于 2021-01-27 17:50:32
问题 I am creating a json body for a REST payload body like so: >>> j = json.loads('["foo", {"bar": ["to_be_replaced", 1.1, 1.0, 2]}]') >>> text = "aaaa" + "\\" + "bbbbb" + "\\" + "cccc" >>> j[1]["bar"][0] = text >>> j ['foo', {'bar': ['aaaa\\bbbbb\\cccc', 1.1, 1.0, 2]}] Annoyingly, the format expected on the other side is like so "aaaa\bbbb\cccc". A terrible idea, I know. I have tried everything and am starting to believe it's simply impossible to store text in this format in a json object. Is

Line break represented as “\r” on Mac?

大憨熊 提交于 2021-01-27 13:24:24
问题 See fiddle: if you press Enter in the textarea on a recent Mac, the newline character appears to be represented by \r , which would be in direct contrast to the answers to this, this and this question and to Wikipedia. To summarise these links: \r represents a line break on old Macs (OS 9 and before) \n represents a line break on UNIX systems (OS X, Linux) \r\n represents a line break on Windows. When I press Enter in the JSFiddle, I get the following result (OS X 10.11.6): textarea: \r span:

How do I escape closing '/' in HTML tags in JSON with Python?

此生再无相见时 提交于 2021-01-22 08:02:13
问题 Note: This question is very close to Embedding JSON objects in script tags, but the responses to that question provides what I already know (that in JSON / == \/ ). I want to know how to do that escaping. The HTML spec prohibits closed HTML tags anywhere within a <script> element. So, this causes parse errors: <script> var assets = [{ "asset_created": null, "asset_id": "575155948f7d4c4ebccb02d4e8f84d2f", "body": "<script></script>" }]; </script> In my case, I'm generating the invalid

“??*” C++ escape sequence [duplicate]

断了今生、忘了曾经 提交于 2021-01-20 09:17:05
问题 This question already has answers here : Are digraphs and trigraphs in use today? [closed] (5 answers) Closed 6 years ago . Note that the * in the title is meant to be a placeholder, in my case the culprit was ??[ . I just came over C++ (also "C") escape sequences, formed by double question marks. What was this ever used for and why is it still there? I have ascii-85 encoded text where double question marks seldom occur and just spent an afternoon ripping the hair from my head while