How to get âFOO=bar.cpp meld a/$FOO b/$FOOâ to work the way I expect it to?
Clash Royale CLAN TAG#URR8PPP
up vote
1
down vote
favorite
As far as I understand, to compare the same file in separate directories I should be able to do this:
FOO=bar.cpp meld a/$FOO b/$FOO
However, it doesn't work, as if $FOO
is an empty string. This not surprisingly works:
(FOO=bar.cpp && meld a/$FOO b/$FOO)
My question is why does the first example not work?
bash environment-variables
add a comment |Â
up vote
1
down vote
favorite
As far as I understand, to compare the same file in separate directories I should be able to do this:
FOO=bar.cpp meld a/$FOO b/$FOO
However, it doesn't work, as if $FOO
is an empty string. This not surprisingly works:
(FOO=bar.cpp && meld a/$FOO b/$FOO)
My question is why does the first example not work?
bash environment-variables
Are you sureFOO=bar.cpp echo a/$FOO b/$FOO
give youa/$FOO b/$FOO
? I think no
â cuonglm
Feb 27 at 3:59
Oops, I had setFOO
globally whilst experimenting - I've deleted that example.
â Ken Y-N
Feb 27 at 4:03
add a comment |Â
up vote
1
down vote
favorite
up vote
1
down vote
favorite
As far as I understand, to compare the same file in separate directories I should be able to do this:
FOO=bar.cpp meld a/$FOO b/$FOO
However, it doesn't work, as if $FOO
is an empty string. This not surprisingly works:
(FOO=bar.cpp && meld a/$FOO b/$FOO)
My question is why does the first example not work?
bash environment-variables
As far as I understand, to compare the same file in separate directories I should be able to do this:
FOO=bar.cpp meld a/$FOO b/$FOO
However, it doesn't work, as if $FOO
is an empty string. This not surprisingly works:
(FOO=bar.cpp && meld a/$FOO b/$FOO)
My question is why does the first example not work?
bash environment-variables
edited Feb 27 at 4:02
asked Feb 27 at 3:56
Ken Y-N
1375
1375
Are you sureFOO=bar.cpp echo a/$FOO b/$FOO
give youa/$FOO b/$FOO
? I think no
â cuonglm
Feb 27 at 3:59
Oops, I had setFOO
globally whilst experimenting - I've deleted that example.
â Ken Y-N
Feb 27 at 4:03
add a comment |Â
Are you sureFOO=bar.cpp echo a/$FOO b/$FOO
give youa/$FOO b/$FOO
? I think no
â cuonglm
Feb 27 at 3:59
Oops, I had setFOO
globally whilst experimenting - I've deleted that example.
â Ken Y-N
Feb 27 at 4:03
Are you sure
FOO=bar.cpp echo a/$FOO b/$FOO
give you a/$FOO b/$FOO
? I think noâ cuonglm
Feb 27 at 3:59
Are you sure
FOO=bar.cpp echo a/$FOO b/$FOO
give you a/$FOO b/$FOO
? I think noâ cuonglm
Feb 27 at 3:59
Oops, I had set
FOO
globally whilst experimenting - I've deleted that example.â Ken Y-N
Feb 27 at 4:03
Oops, I had set
FOO
globally whilst experimenting - I've deleted that example.â Ken Y-N
Feb 27 at 4:03
add a comment |Â
1 Answer
1
active
oldest
votes
up vote
3
down vote
accepted
In:
FOO=bar.cpp meld a/$FOO b/$FOO
It's a Simple Command, so FOO=bar.cpp
isn't executed at the time $FOO
was expanded.
In:
FOO=bar.cpp && meld a/$FOO b/$FOO
There're 2 commands:
FOO=bar.cpp
and:
meld a/$FOO b/$FOO
When parameter substitution performed in meld a/$FOO b/$FOO
, FOO=bar.cpp
was executed, so FOO
was set to bar.cpp
.
So basically a Simple Command cannot do what I hoped it could?
â Ken Y-N
Feb 27 at 4:35
@KenY-N yes,(FOO=bar.cpp; meld "a/$FOO" "b/$FOO")
is the way to go if you don't want toFOO
retains after command finish. Note the double quotes. You can use any statement termination like;
above instead of&&
.
â cuonglm
Feb 27 at 4:53
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
In:
FOO=bar.cpp meld a/$FOO b/$FOO
It's a Simple Command, so FOO=bar.cpp
isn't executed at the time $FOO
was expanded.
In:
FOO=bar.cpp && meld a/$FOO b/$FOO
There're 2 commands:
FOO=bar.cpp
and:
meld a/$FOO b/$FOO
When parameter substitution performed in meld a/$FOO b/$FOO
, FOO=bar.cpp
was executed, so FOO
was set to bar.cpp
.
So basically a Simple Command cannot do what I hoped it could?
â Ken Y-N
Feb 27 at 4:35
@KenY-N yes,(FOO=bar.cpp; meld "a/$FOO" "b/$FOO")
is the way to go if you don't want toFOO
retains after command finish. Note the double quotes. You can use any statement termination like;
above instead of&&
.
â cuonglm
Feb 27 at 4:53
add a comment |Â
up vote
3
down vote
accepted
In:
FOO=bar.cpp meld a/$FOO b/$FOO
It's a Simple Command, so FOO=bar.cpp
isn't executed at the time $FOO
was expanded.
In:
FOO=bar.cpp && meld a/$FOO b/$FOO
There're 2 commands:
FOO=bar.cpp
and:
meld a/$FOO b/$FOO
When parameter substitution performed in meld a/$FOO b/$FOO
, FOO=bar.cpp
was executed, so FOO
was set to bar.cpp
.
So basically a Simple Command cannot do what I hoped it could?
â Ken Y-N
Feb 27 at 4:35
@KenY-N yes,(FOO=bar.cpp; meld "a/$FOO" "b/$FOO")
is the way to go if you don't want toFOO
retains after command finish. Note the double quotes. You can use any statement termination like;
above instead of&&
.
â cuonglm
Feb 27 at 4:53
add a comment |Â
up vote
3
down vote
accepted
up vote
3
down vote
accepted
In:
FOO=bar.cpp meld a/$FOO b/$FOO
It's a Simple Command, so FOO=bar.cpp
isn't executed at the time $FOO
was expanded.
In:
FOO=bar.cpp && meld a/$FOO b/$FOO
There're 2 commands:
FOO=bar.cpp
and:
meld a/$FOO b/$FOO
When parameter substitution performed in meld a/$FOO b/$FOO
, FOO=bar.cpp
was executed, so FOO
was set to bar.cpp
.
In:
FOO=bar.cpp meld a/$FOO b/$FOO
It's a Simple Command, so FOO=bar.cpp
isn't executed at the time $FOO
was expanded.
In:
FOO=bar.cpp && meld a/$FOO b/$FOO
There're 2 commands:
FOO=bar.cpp
and:
meld a/$FOO b/$FOO
When parameter substitution performed in meld a/$FOO b/$FOO
, FOO=bar.cpp
was executed, so FOO
was set to bar.cpp
.
edited Feb 27 at 4:21
answered Feb 27 at 4:12
cuonglm
97.3k21185278
97.3k21185278
So basically a Simple Command cannot do what I hoped it could?
â Ken Y-N
Feb 27 at 4:35
@KenY-N yes,(FOO=bar.cpp; meld "a/$FOO" "b/$FOO")
is the way to go if you don't want toFOO
retains after command finish. Note the double quotes. You can use any statement termination like;
above instead of&&
.
â cuonglm
Feb 27 at 4:53
add a comment |Â
So basically a Simple Command cannot do what I hoped it could?
â Ken Y-N
Feb 27 at 4:35
@KenY-N yes,(FOO=bar.cpp; meld "a/$FOO" "b/$FOO")
is the way to go if you don't want toFOO
retains after command finish. Note the double quotes. You can use any statement termination like;
above instead of&&
.
â cuonglm
Feb 27 at 4:53
So basically a Simple Command cannot do what I hoped it could?
â Ken Y-N
Feb 27 at 4:35
So basically a Simple Command cannot do what I hoped it could?
â Ken Y-N
Feb 27 at 4:35
@KenY-N yes,
(FOO=bar.cpp; meld "a/$FOO" "b/$FOO")
is the way to go if you don't want to FOO
retains after command finish. Note the double quotes. You can use any statement termination like ;
above instead of &&
.â cuonglm
Feb 27 at 4:53
@KenY-N yes,
(FOO=bar.cpp; meld "a/$FOO" "b/$FOO")
is the way to go if you don't want to FOO
retains after command finish. Note the double quotes. You can use any statement termination like ;
above instead of &&
.â cuonglm
Feb 27 at 4:53
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
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f426844%2fhow-to-get-foo-bar-cpp-meld-a-foo-b-foo-to-work-the-way-i-expect-it-to%23new-answer', 'question_page');
);
Post as a guest
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
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
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
Are you sure
FOO=bar.cpp echo a/$FOO b/$FOO
give youa/$FOO b/$FOO
? I think noâ cuonglm
Feb 27 at 3:59
Oops, I had set
FOO
globally whilst experimenting - I've deleted that example.â Ken Y-N
Feb 27 at 4:03