There is a.sh
:
#!/bin/bash
foo=':bar baz:'
declare varvar=aaaaaa
export xyz=abc
echo "$foo ok"
hoge=huga env piyo=alice bash -i
Run ./a.sh
(|
is cursor, >
is prompt):
:bar baz: ok
> |
There is the input:
echo "foo: '$foo'"
echo "varvar: '$varvar'"
echo "xyz: '$xyz'"
echo "hoge: '$hoge'"
echo "piyo: '$piyo'"
Expected output:
> echo "foo: '$foo'"
foo: ':bar baz:'
> echo "varvar: '$varvar'"
varvar: 'aaaaaa'
> echo "xyz: '$xyz'"
xyz: 'abc'
> echo "hoge: '$hoge'"
hoge: 'huga'
> echo "piyo: '$piyo'"
piyo: 'alice'
> |
Actual output:
> echo "foo: '$foo'"
foo: ''
> echo "varvar: '$varvar'"
varvar: ''
> echo "xyz: '$xyz'"
xyz: 'abc'
> echo "hoge: '$hoge'"
hoge: 'huga'
> echo "piyo: '$piyo'"
piyo: 'alice'
> |
How do I get $foo
and $varvar
to display correctly?
xyz
. Or make the assignment as withhoge
orpiyo
. It's unclear what the question is as you have the answer in your code. – Kusalananda Feb 16 '22 at 07:12export
, by assigning them at the start of a command's command line or by setting them in the arguments toenv
when using that tool to launch the command. – Kusalananda Feb 16 '22 at 07:29