Assign variable using multiple lines
Clash Royale CLAN TAG#URR8PPP
up vote
0
down vote
favorite
I have a function
f()
echo 777
and a variable to which I assign the "return value" of the function.
x=$(f)
Very concise! However, in my real code, the variable and function names are quite a bit longer and the function also eats positional arguments, so that concise line above, gets very long. Since I like to keep things tidy, I would like to break the code above in two lines.
x=
$(f)
Still works! But: keeping things tidy also means respecting the indentation, so that gives something like
if foo
x=
$(f)
fi
which does not work anymore due to whitespaces! Is there a good workaround for this?
bash newlines assignment
add a comment |Â
up vote
0
down vote
favorite
I have a function
f()
echo 777
and a variable to which I assign the "return value" of the function.
x=$(f)
Very concise! However, in my real code, the variable and function names are quite a bit longer and the function also eats positional arguments, so that concise line above, gets very long. Since I like to keep things tidy, I would like to break the code above in two lines.
x=
$(f)
Still works! But: keeping things tidy also means respecting the indentation, so that gives something like
if foo
x=
$(f)
fi
which does not work anymore due to whitespaces! Is there a good workaround for this?
bash newlines assignment
add a comment |Â
up vote
0
down vote
favorite
up vote
0
down vote
favorite
I have a function
f()
echo 777
and a variable to which I assign the "return value" of the function.
x=$(f)
Very concise! However, in my real code, the variable and function names are quite a bit longer and the function also eats positional arguments, so that concise line above, gets very long. Since I like to keep things tidy, I would like to break the code above in two lines.
x=
$(f)
Still works! But: keeping things tidy also means respecting the indentation, so that gives something like
if foo
x=
$(f)
fi
which does not work anymore due to whitespaces! Is there a good workaround for this?
bash newlines assignment
I have a function
f()
echo 777
and a variable to which I assign the "return value" of the function.
x=$(f)
Very concise! However, in my real code, the variable and function names are quite a bit longer and the function also eats positional arguments, so that concise line above, gets very long. Since I like to keep things tidy, I would like to break the code above in two lines.
x=
$(f)
Still works! But: keeping things tidy also means respecting the indentation, so that gives something like
if foo
x=
$(f)
fi
which does not work anymore due to whitespaces! Is there a good workaround for this?
bash newlines assignment
bash newlines assignment
asked 8 mins ago
pfnuesel
2,62741838
2,62741838
add a comment |Â
add a comment |Â
active
oldest
votes
active
oldest
votes
active
oldest
votes
active
oldest
votes
active
oldest
votes
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%2f478804%2fassign-variable-using-multiple-lines%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