Bash: how to properly accept user input?
Clash Royale CLAN TAG#URR8PPP
up vote
0
down vote
favorite
I couldn't find an example online but I'm sure I've seen shell coders use $1:--
to accept user input. Here's an example:
#!/bin/bash
var="$1:--"
echo "$var"
Then, run it:
$ ./test.sh "this is a test"
My question is: how is using "$1:--"
to accept user input different from "$1"
?
bash shell-script shell command-line input
New contributor
add a comment |Â
up vote
0
down vote
favorite
I couldn't find an example online but I'm sure I've seen shell coders use $1:--
to accept user input. Here's an example:
#!/bin/bash
var="$1:--"
echo "$var"
Then, run it:
$ ./test.sh "this is a test"
My question is: how is using "$1:--"
to accept user input different from "$1"
?
bash shell-script shell command-line input
New contributor
add a comment |Â
up vote
0
down vote
favorite
up vote
0
down vote
favorite
I couldn't find an example online but I'm sure I've seen shell coders use $1:--
to accept user input. Here's an example:
#!/bin/bash
var="$1:--"
echo "$var"
Then, run it:
$ ./test.sh "this is a test"
My question is: how is using "$1:--"
to accept user input different from "$1"
?
bash shell-script shell command-line input
New contributor
I couldn't find an example online but I'm sure I've seen shell coders use $1:--
to accept user input. Here's an example:
#!/bin/bash
var="$1:--"
echo "$var"
Then, run it:
$ ./test.sh "this is a test"
My question is: how is using "$1:--"
to accept user input different from "$1"
?
bash shell-script shell command-line input
bash shell-script shell command-line input
New contributor
New contributor
New contributor
asked 12 mins ago
user318062
1
1
New contributor
New contributor
add a comment |Â
add a comment |Â
active
oldest
votes
active
oldest
votes
active
oldest
votes
active
oldest
votes
active
oldest
votes
user318062 is a new contributor. Be nice, and check out our Code of Conduct.
user318062 is a new contributor. Be nice, and check out our Code of Conduct.
user318062 is a new contributor. Be nice, and check out our Code of Conduct.
user318062 is a new contributor. Be nice, and check out our Code of Conduct.
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%2f478178%2fbash-how-to-properly-accept-user-input%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