Why double double quotes make string run as function?
up vote
-1
down vote
favorite
A simple function receive two arguments and add and
,then print them.
function myprint(){ echo "$1 and $2";}
It works.
myprint xx yy
xx and yy
It is a string,bash parse it separately.
"myprint xx yy"
bash: myprint xx yy: command not found
Why double double quotes make string run as function?
""myprint xx yy""
xx and yy
bash smart-quotes
add a comment |
up vote
-1
down vote
favorite
A simple function receive two arguments and add and
,then print them.
function myprint(){ echo "$1 and $2";}
It works.
myprint xx yy
xx and yy
It is a string,bash parse it separately.
"myprint xx yy"
bash: myprint xx yy: command not found
Why double double quotes make string run as function?
""myprint xx yy""
xx and yy
bash smart-quotes
add a comment |
up vote
-1
down vote
favorite
up vote
-1
down vote
favorite
A simple function receive two arguments and add and
,then print them.
function myprint(){ echo "$1 and $2";}
It works.
myprint xx yy
xx and yy
It is a string,bash parse it separately.
"myprint xx yy"
bash: myprint xx yy: command not found
Why double double quotes make string run as function?
""myprint xx yy""
xx and yy
bash smart-quotes
A simple function receive two arguments and add and
,then print them.
function myprint(){ echo "$1 and $2";}
It works.
myprint xx yy
xx and yy
It is a string,bash parse it separately.
"myprint xx yy"
bash: myprint xx yy: command not found
Why double double quotes make string run as function?
""myprint xx yy""
xx and yy
bash smart-quotes
bash smart-quotes
asked Nov 18 at 12:24
scrapy
1765
1765
add a comment |
add a comment |
1 Answer
1
active
oldest
votes
up vote
3
down vote
accepted
Your "double double quotes" are in fact not nested. Two times a double quote is opened and closed right away.
""myprint xx yy""
^^ this is one pair of quotes with empty content
^^ this is anther pair with empty content
^^^^^^^^^^^^^^^ this is not quoted at all
In effect ""myprint
is the command named: the empty string concatenated with "myprint", this resolves to the myprint
function; and the last argument is the string "yy" concatenated with the empty string.
So you get unquoted myprint xx yy
. The whole original command behaves as such.
add a comment |
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
3
down vote
accepted
Your "double double quotes" are in fact not nested. Two times a double quote is opened and closed right away.
""myprint xx yy""
^^ this is one pair of quotes with empty content
^^ this is anther pair with empty content
^^^^^^^^^^^^^^^ this is not quoted at all
In effect ""myprint
is the command named: the empty string concatenated with "myprint", this resolves to the myprint
function; and the last argument is the string "yy" concatenated with the empty string.
So you get unquoted myprint xx yy
. The whole original command behaves as such.
add a comment |
up vote
3
down vote
accepted
Your "double double quotes" are in fact not nested. Two times a double quote is opened and closed right away.
""myprint xx yy""
^^ this is one pair of quotes with empty content
^^ this is anther pair with empty content
^^^^^^^^^^^^^^^ this is not quoted at all
In effect ""myprint
is the command named: the empty string concatenated with "myprint", this resolves to the myprint
function; and the last argument is the string "yy" concatenated with the empty string.
So you get unquoted myprint xx yy
. The whole original command behaves as such.
add a comment |
up vote
3
down vote
accepted
up vote
3
down vote
accepted
Your "double double quotes" are in fact not nested. Two times a double quote is opened and closed right away.
""myprint xx yy""
^^ this is one pair of quotes with empty content
^^ this is anther pair with empty content
^^^^^^^^^^^^^^^ this is not quoted at all
In effect ""myprint
is the command named: the empty string concatenated with "myprint", this resolves to the myprint
function; and the last argument is the string "yy" concatenated with the empty string.
So you get unquoted myprint xx yy
. The whole original command behaves as such.
Your "double double quotes" are in fact not nested. Two times a double quote is opened and closed right away.
""myprint xx yy""
^^ this is one pair of quotes with empty content
^^ this is anther pair with empty content
^^^^^^^^^^^^^^^ this is not quoted at all
In effect ""myprint
is the command named: the empty string concatenated with "myprint", this resolves to the myprint
function; and the last argument is the string "yy" concatenated with the empty string.
So you get unquoted myprint xx yy
. The whole original command behaves as such.
edited Nov 18 at 14:47
community wiki
2 revs
Kamil Maciorowski
add a comment |
add a comment |
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fsuperuser.com%2fquestions%2f1376433%2fwhy-double-double-quotes-make-string-run-as-function%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown