quotes

How to keep quotes in Bash arguments?

允我心安 提交于 2019-11-26 21:54:49
I have a Bash script where I want to keep quotes in the arguments passed. Example: ./test.sh this is "some test" then I want to use those arguments, and re-use them, including quotes and quotes around the whole argument list. I tried using \"$@\" , but that removes the quotes inside the list. How do I accomplish this? Randy Sugianto 'Yuku' Just use single quotes around the string with the double quotes: ./test.sh this is '"some test"' So the double quotes of inside the single quotes were also interpreted as string. But I would recommend to put the whole string between single quotes: ./test.sh

How to escape double quotes in title attribute

≯℡__Kan透↙ 提交于 2019-11-26 21:30:57
I am trying to use a string that contains double quotes in the title attribute of an anchor. So far I tried these: <a href=".." title="Some \"text\"">Some text</a> <!-- title looks like `Some \` --!> and <a href=".." title="Some "text"">Some text</a> <!-- title looks like `Some ` --!> Please note that using single quotes is not an option. This variant - <a href=".." title="Some "text"">Some text</a> Is correct and it works as expected - you see normal quotes in rendered page. Dave EDIT: Link appears to be dead, so here's a snippet of the escape characters taken from a cached page on archive

How to handle double quotes in string before XPath evaluation?

瘦欲@ 提交于 2019-11-26 21:06:43
In the function below, when string in $keyword contains double quotes, it does create a "Warning: DOMXPath::evaluate(): Invalid expression" : $keyword = 'This is "causing" an error'; $xPath->evaluate('boolean(//img[contains(@alt, "'.$keyword.'")])'); What should I do to prep $keyword for the evaluate xpath expression? The full function code: $keyword = trim(strtolower(rseo_getKeyword($post))); function sx_function($heading, $post){ $content = $post->post_content; if($content=="" || !class_exists('DOMDocument')) return false; $keyword = trim(strtolower(rseo_getKeyword($post))); @$dom = new

HTML attribute with/without quotes

牧云@^-^@ 提交于 2019-11-26 21:02:58
Is there any difference between <iframe src="www.example.com" width=100%></iframe> and <iframe src="www.example.com" width="100%"></iframe> I've tried both and both seem to work, but I'm asking just in case there's something I need to be careful with (like maybe units other than %, etc.) Davit It is all about the true validity of HTML markup. It's for what W3C (WWW Consortium) work for. Many things might work in HTML but they have to be validated in order to be more carefully recognized by the web browser. You can even omit the <html> and </html> tags at the start and end, but it is not

Difference between single and double quotes in awk

核能气质少年 提交于 2019-11-26 20:45:23
问题 I have this awk statement: glb_library="my_library" awk " /^Direct Dependers of/ { next } /^---/ { next } /^$glb_library:/ { ver=\$0; next } { gsub(/[[:space:]]/, '', \$0); print ver':'\$0 } " file Basically, I have enclosed the awk code in double quotes so that the shell variable glb_library is expanded. I have made sure to escape the $ character to prevent the shell from expanding $0 . Followed the guidance from here. awk gives me this error: awk: syntax error at source line 5 context is {

Preserving quotes in bash function parameters

折月煮酒 提交于 2019-11-26 20:10:49
问题 What I'd like to do is take, as an input to a function, a line that may include quotes (single or double) and echo that line exactly as it was provided to the function. For instance: function doit { printf "%s " ${@} eval "${@}" printf " # [%3d]\n" ${?} } Which, given the following input doit VAR=42 doit echo 'single quote $VAR' doit echo "double quote $VAR" Yields the following: VAR=42 # [ 0] echo single quote $VAR # [ 0] echo double quote 42 # [ 0] So the semantics of the variable expansion

Why are some object-literal properties quoted and others not? [duplicate]

人盡茶涼 提交于 2019-11-26 19:53:41
问题 This question already has an answer here: What is the difference between object keys with quotes and without quotes? 5 answers I see this all the time: object literals declared such that some keys are surrounded with quotes and others are not. An example from jQuery 1.4.2: jQuery.props = { "for": "htmlFor", "class": "className", readonly: "readOnly", maxlength: "maxLength", cellspacing: "cellSpacing", rowspan: "rowSpan", colspan: "colSpan", tabindex: "tabIndex", usemap: "useMap", frameborder:

How do I include a literal double quote in a custom CMake command?

独自空忆成欢 提交于 2019-11-26 18:31:58
问题 I'm trying to create a custom command that runs with some environment variables, such as LDFLAGS, whose value needs to be quoted if it contains spaces: LDFLAGS="-Lmydir -Lmyotherdir" I cannot find a way to include this argument in a CMake custom command, due to CMake's escaping rules. Here's what I've tried so far: COMMAND LDFLAGS="-Ldir -Ldir2" echo blah VERBATIM) yields "LDFLAGS=\"-Ldir -Ldir2\"" echo blah COMMAND LDFLAGS=\"-Ldir -Ldir2\" echo blah VERBATIM) yields LDFLAGS=\"-Ldir -Ldir2\"

Are quotes around hash keys a good practice in Perl?

女生的网名这么多〃 提交于 2019-11-26 18:21:10
问题 Is it a good idea to quote keys when using a hash in Perl? I am working on an extremely large legacy Perl code base and trying to adopt a lot of the best practices suggested by Damian Conway in Perl Best Practices. I know that best practices are always a touchy subject with programmers, but hopefully I can get some good answers on this one without starting a flame war. I also know that this is probably something that a lot of people wouldn't argue over due to it being a minor issue, but I'm

Write CSV To File Without Enclosures In PHP

大兔子大兔子 提交于 2019-11-26 18:10:21
问题 Is there a native function or solid class/library for writing an array as a line in a CSV file without enclosures? fputcsv will default to " if nothing is passed in for the enclosure param. Google is failing me (returning results for a whole bunch of pages about fputcsv ), and PEAR's libraries do more or less the same things as fputcsv . Something that works exactly like fputcsv , but will allow the fields to remain unquoted. currently: "field 1","field 2",field3hasNoSpaces desired: field 1