How to get “FOO=bar.cpp meld a/$FOO b/$FOO” to work the way I expect it to?

The name of the pictureThe name of the pictureThe name of the pictureClash 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?







share|improve this question






















  • 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














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?







share|improve this question






















  • 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












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?







share|improve this question














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?









share|improve this question













share|improve this question




share|improve this question








edited Feb 27 at 4:02

























asked Feb 27 at 3:56









Ken Y-N

1375




1375











  • 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
















  • 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















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










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.






share|improve this answer






















  • 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










Your Answer







StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "106"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);

else
createEditor();

);

function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
convertImagesToLinks: false,
noModals: false,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);



);








 

draft saved


draft discarded


















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






























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.






share|improve this answer






















  • 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














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.






share|improve this answer






















  • 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












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.






share|improve this answer














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.







share|improve this answer














share|improve this answer



share|improve this answer








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 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
















  • 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















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












 

draft saved


draft discarded


























 


draft saved


draft discarded














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













































































Popular posts from this blog

How to check contact read email or not when send email to Individual?

Displaying single band from multi-band raster using QGIS

How many registers does an x86_64 CPU actually have?