$USER already set when wanting to read username from user
Clash Royale CLAN TAG#URR8PPP
up vote
0
down vote
favorite
I made this code
while [ -z "$USER" ]; do
>&2 echo -n 'Your desired User : '
read USER
done
But this doesn't work because $USER
is taken from the current user running the script, which isn't what I want.
How can I avoid this in the future for the $USER
variable and also other variables where this could happen? Like $PATCH
or similar
bash environment-variables
add a comment |Â
up vote
0
down vote
favorite
I made this code
while [ -z "$USER" ]; do
>&2 echo -n 'Your desired User : '
read USER
done
But this doesn't work because $USER
is taken from the current user running the script, which isn't what I want.
How can I avoid this in the future for the $USER
variable and also other variables where this could happen? Like $PATCH
or similar
bash environment-variables
add a comment |Â
up vote
0
down vote
favorite
up vote
0
down vote
favorite
I made this code
while [ -z "$USER" ]; do
>&2 echo -n 'Your desired User : '
read USER
done
But this doesn't work because $USER
is taken from the current user running the script, which isn't what I want.
How can I avoid this in the future for the $USER
variable and also other variables where this could happen? Like $PATCH
or similar
bash environment-variables
I made this code
while [ -z "$USER" ]; do
>&2 echo -n 'Your desired User : '
read USER
done
But this doesn't work because $USER
is taken from the current user running the script, which isn't what I want.
How can I avoid this in the future for the $USER
variable and also other variables where this could happen? Like $PATCH
or similar
bash environment-variables
edited Oct 21 '17 at 9:19
Kusalananda
105k14209326
105k14209326
asked Oct 21 '17 at 8:48
Freedo
407417
407417
add a comment |Â
add a comment |Â
1 Answer
1
active
oldest
votes
up vote
2
down vote
accepted
Use lower-case variable names, or know exactly what upper-case variable names to avoid using.
For non-environment variables (i.e. shell variables), just use lower-case:
while [ -z "$user" ]; do
read -p 'User name: ' user
done
lol so dumb, I don't know why I didn't thought about that...I guess it doesn't worth the effort to use uppercase variables in this case right?
â Freedo
Oct 21 '17 at 8:53
@Freedo Not really, unless you explicitly want to change system environment variables likePATH
etc.
â Kusalananda
Oct 21 '17 at 8:55
add a comment |Â
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
2
down vote
accepted
Use lower-case variable names, or know exactly what upper-case variable names to avoid using.
For non-environment variables (i.e. shell variables), just use lower-case:
while [ -z "$user" ]; do
read -p 'User name: ' user
done
lol so dumb, I don't know why I didn't thought about that...I guess it doesn't worth the effort to use uppercase variables in this case right?
â Freedo
Oct 21 '17 at 8:53
@Freedo Not really, unless you explicitly want to change system environment variables likePATH
etc.
â Kusalananda
Oct 21 '17 at 8:55
add a comment |Â
up vote
2
down vote
accepted
Use lower-case variable names, or know exactly what upper-case variable names to avoid using.
For non-environment variables (i.e. shell variables), just use lower-case:
while [ -z "$user" ]; do
read -p 'User name: ' user
done
lol so dumb, I don't know why I didn't thought about that...I guess it doesn't worth the effort to use uppercase variables in this case right?
â Freedo
Oct 21 '17 at 8:53
@Freedo Not really, unless you explicitly want to change system environment variables likePATH
etc.
â Kusalananda
Oct 21 '17 at 8:55
add a comment |Â
up vote
2
down vote
accepted
up vote
2
down vote
accepted
Use lower-case variable names, or know exactly what upper-case variable names to avoid using.
For non-environment variables (i.e. shell variables), just use lower-case:
while [ -z "$user" ]; do
read -p 'User name: ' user
done
Use lower-case variable names, or know exactly what upper-case variable names to avoid using.
For non-environment variables (i.e. shell variables), just use lower-case:
while [ -z "$user" ]; do
read -p 'User name: ' user
done
answered Oct 21 '17 at 8:51
Kusalananda
105k14209326
105k14209326
lol so dumb, I don't know why I didn't thought about that...I guess it doesn't worth the effort to use uppercase variables in this case right?
â Freedo
Oct 21 '17 at 8:53
@Freedo Not really, unless you explicitly want to change system environment variables likePATH
etc.
â Kusalananda
Oct 21 '17 at 8:55
add a comment |Â
lol so dumb, I don't know why I didn't thought about that...I guess it doesn't worth the effort to use uppercase variables in this case right?
â Freedo
Oct 21 '17 at 8:53
@Freedo Not really, unless you explicitly want to change system environment variables likePATH
etc.
â Kusalananda
Oct 21 '17 at 8:55
lol so dumb, I don't know why I didn't thought about that...I guess it doesn't worth the effort to use uppercase variables in this case right?
â Freedo
Oct 21 '17 at 8:53
lol so dumb, I don't know why I didn't thought about that...I guess it doesn't worth the effort to use uppercase variables in this case right?
â Freedo
Oct 21 '17 at 8:53
@Freedo Not really, unless you explicitly want to change system environment variables like
PATH
etc.â Kusalananda
Oct 21 '17 at 8:55
@Freedo Not really, unless you explicitly want to change system environment variables like
PATH
etc.â Kusalananda
Oct 21 '17 at 8:55
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%2f399503%2fuser-already-set-when-wanting-to-read-username-from-user%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