quoting

Backslashes in Powershell

。_饼干妹妹 提交于 2019-12-08 19:27:10
问题 Why does the string for the -split parameter require two backslashes while the string for the -join parameter requires only one backslash? The backtick is the escape character in Powershell. What does a backslash preceding a character do for you? $path = 'C:\folder\test\unit1\testing\results\report.txt' $path -split '\\' -notlike '*test*' -join '\' http://powershell.com/cs/blogs/tips/archive/2014/06/17/fun-with-path-names.aspx 回答1: -split splits on a regex by default. So it is the regex that

How to pass JSON (string data) to PowerShell?

匆匆过客 提交于 2019-12-08 07:04:53
问题 I'm passing the following as an argument to powershell (v4 on w7): -debugWrite -fileName SettingsFile -jsonContent { "c": "some setting", "d": "unknown", "b": "some thing", "a": 1 } But PS gets hung up on the JSON. I've tried delimiting the \double-quotes\ and putting everything after -jsonContent in 'single quotes', but to no avail. Here is the Windows 7 (PS4) environment PS is running in: note: "..." obfuscation refers to the same dir. IOW, all files live in the same directory. A batch file

Put $$ in dollar-quoted string in PostgreSQL

℡╲_俬逩灬. 提交于 2019-12-07 14:33:44
问题 I have a function in Postgres: CREATE OR REPLACE FUNCTION upsert(sql_insert text, sql_update text) RETURNS integer AS $BODY$ BEGIN EXECUTE sql_insert; RETURN 1; EXCEPTION WHEN unique_violation THEN EXECUTE sql_update; RETURN 2; END; $BODY$ LANGUAGE 'plpgsql' VOLATILE COST 100; ALTER FUNCTION upsert(text, text) OWNER TO dce; I usually use this query to call that function: select upsert( $$INSERT INTO zz(a, b) VALUES (66, 'hahahaha')$$, $$UPDATE zz SET a=66, b='hahahaha' WHERE a=66$$ ) It works

How can I do ANSI C quoting of an existing bash variable?

梦想与她 提交于 2019-12-07 09:56:26
问题 I have looked at this question, but it does not cover my use case. Suppose I have the variable foo which holds the four-character literal \x60 . I want to perform ANSI C Quoting on the contents of this variable and store it into another variable bar . I tried the following, but none of them achieved the desired effect. bar=$'$foo' echo $bar bar=$"$foo" echo $bar Output: $foo \x61 Desired output (actual value of \x61 ): a How might I achieve this in the general case, including non-printable

My Zend Framework 'quoting' mess

耗尽温柔 提交于 2019-12-07 07:49:19
问题 I've got a probably very simple issue to which I can't find a satisfactory (subjectively seen) answer in the Zend Framework manual or elsewhere... There are so many ways how I can hand over my php variables to my sql queries that I lost the overview and probably I lack some understanding about quoting in general. Prepared Statements $sql = "SELECT this, that FROM table WHERE id = ? AND restriction = ?"; $stmt = $this->_db->query($sql, array($myId, $myValue)); $result = $stmt->fetchAll(); I

Can't pass a script block as a parameter to powershell.exe via -Command

送分小仙女□ 提交于 2019-12-06 14:00:46
问题 I'm trying this $Global:commandBlock={ Start-Transcript -path $projectFolder\gruntLog.txt; grunt $argList; Stop-Transcript } $cmdProc=start-process powershell -ArgumentList ('-command `$Global:commandBlock') -WorkingDirectory $fwd -PassThru -NoNewWindow:$NoNewWindow And keep getting $commandBlock : The term '$Global:commandBlock' is not recognized as the name of a cmdlet, function, script file, or operable program. My guess was it has to do with scope. But making variable global didn't help.

psql passed variable

断了今生、忘了曾经 提交于 2019-12-06 06:58:07
New to psql scripting. I try to pass a variable to a psql script but get an error: psql -v dateav="2012-01-28" mcdb -p 5555 -U admin -q -t -A -c 'select count (client_name) from v_activities where scheduled_start_date like :'dateav';' ERROR: syntax error at or near ":" LINE 1: ...) from v_activities where scheduled_start_date like :dateav; Any ideas? Would work like this: echo "select count (client_name) from v_activities \ where scheduled_start_date like :'dateav'" | \ psql -v dateav="2012-01-28" mcdb -p 5555 -U admin -q -t -A Explain: I quote the manual here : -c command (...) command must

Raising error in postgreSQL

无人久伴 提交于 2019-12-05 23:29:07
问题 CREATE OR REPLACE FUNCTION msgfailerror() RETURNS trigger AS ' BEGIN IF NEW.noces< new.first_column THEN RAISE EXCEPTION 'cannot have a negative salary'; END IF; return new; END' LANGUAGE plpgsql Trigger create trigger msgfail before insert on first for each row execute procedure msgfailerror() Giving error: syntax error at or near "cannot" LINE 5: RAISE EXCEPTION 'cannot have a negative ... I have almost one validation for each field of row. I want trigger to check all validations while

Put $$ in dollar-quoted string in PostgreSQL

前提是你 提交于 2019-12-05 18:40:40
I have a function in Postgres: CREATE OR REPLACE FUNCTION upsert(sql_insert text, sql_update text) RETURNS integer AS $BODY$ BEGIN EXECUTE sql_insert; RETURN 1; EXCEPTION WHEN unique_violation THEN EXECUTE sql_update; RETURN 2; END; $BODY$ LANGUAGE 'plpgsql' VOLATILE COST 100; ALTER FUNCTION upsert(text, text) OWNER TO dce; I usually use this query to call that function: select upsert( $$INSERT INTO zz(a, b) VALUES (66, 'hahahaha')$$, $$UPDATE zz SET a=66, b='hahahaha' WHERE a=66$$ ) It works. Unfortunately, my query string cannot contain $$ , like this: select upsert( $$INSERT INTO zz(a, b)

How to quote a perl $symbol in a makefile

孤街醉人 提交于 2019-12-05 16:55:42
In a Makefile, I have a rule to make a figure list from a LaTeX paper by piping the output from a script to a perl expression that increments figure numbers $f++ and prepends Figure $f: to the lines. From a command line, it works fine, as follows: % texdepend -format=1 -print=f MilestonesProject | perl -pe 'unless (/^#/){$f++; s/^/Figure $f: /}' > FIGLIST generating FIGLIST: # texdepend, v0.96 (Michael Friendly (friendly@yorku.ca)) # commandline: texdepend -format=1 -print=f MilestonesProject # FIGS = Figure 1: fig/langren-google-overlay2.pdf Figure 2: fig/mileyears4.png Figure 3: fig/datavis