Avoid evaluation of script arguments as files [BASH, LINUX] [duplicate] The Next CEO of Stack OverflowPreserve Quotes in bash argumentsGet the source directory of a Bash script from within the script itselfHow do I parse command line arguments in Bash?How do I prompt for Yes/No/Cancel input in a Linux shell script?How to check if a program exists from a Bash script?How do I tell if a regular file does not exist in Bash?How can I redirect and append both stdout and stderr to a file with Bash?Looping through the content of a file in BashHow to symlink a file in Linux?Check existence of input argument in a Bash shell scriptHow do I find all files containing specific text on Linux?
What happens if you roll doubles 3 times then land on "Go to jail?"
Is it my responsibility to learn a new technology in my own time my employer wants to implement?
Would this house-rule that treats advantage as a +1 to the roll instead (and disadvantage as -1) and allows them to stack be balanced?
How did people program for Consoles with multiple CPUs?
Does the Brexit deal have to be agreed by both Houses?
What's the point of interval inversion?
What is the point of a new vote on May's deal when the indicative votes suggest she will not win?
How to write the block matrix in LaTex?
Grabbing quick drinks
How to safely derail a train during transit?
How do I go from 300 unfinished/half written blog posts, to published posts?
How to get regions to plot as graphics
How to start emacs in "nothing" mode (`fundamental-mode`)
Trouble understanding the speech of overseas colleagues
Horror movie/show or scene where a horse creature opens its mouth really wide and devours a man in a stables
Why did we only see the N-1 starfighters in one film?
When airplanes disconnect from a tanker during air to air refueling, why do they bank so sharply to the right?
Need some help with wall behind rangetop
Failed to fetch jessie backports repository
I believe this to be a fraud - hired, then asked to cash check and send cash as Bitcoin
How do spells that require an ability check vs. the caster's spell save DC work?
% symbol leads to superlong (forever?) compilations
How can I get through very long and very dry, but also very useful technical documents when learning a new tool?
Why do remote companies require working in the US?
Avoid evaluation of script arguments as files [BASH, LINUX] [duplicate]
The Next CEO of Stack OverflowPreserve Quotes in bash argumentsGet the source directory of a Bash script from within the script itselfHow do I parse command line arguments in Bash?How do I prompt for Yes/No/Cancel input in a Linux shell script?How to check if a program exists from a Bash script?How do I tell if a regular file does not exist in Bash?How can I redirect and append both stdout and stderr to a file with Bash?Looping through the content of a file in BashHow to symlink a file in Linux?Check existence of input argument in a Bash shell scriptHow do I find all files containing specific text on Linux?
This question already has an answer here:
Preserve Quotes in bash arguments
3 answers
As passing arguments to a self made script, I noted they got evaluated by the file-system if that mach, otherwise, just passed as argument. And that is not the behaviour I'm hopping for
giving that code
#!/bin/bash
declare -a array_arg
#build the array of arguments
while test -n "$1"; do array_arg+=( "$1" ); shift
done
#test there is some arguments
if test $#array_arg[@] -eq 0; then echo "ERROR no arguments"
fi
#running resume
echo "number of elements:: $#array_arg[@]"
for ((i = 0; i < $#array_arg[@]; i++ )); do echo "$i>> $array_arg[i]"
done
I will expect that same list of arguments I pass, I will have into the array_arg array
but, if any argument has a wildcard, and match a file, it get resolve with the name of the file/s
lets see an example :
let's observe, the second argument
file2*
how in the instruction
array_arg+=( "$1" )
adds two filenames to the array, instead of the value of $1
while the last argument, do not get changed/resolved/whatever...
Needless to say, I need the arguments as passed to the script, not evaluated
linux bash shell ubuntu
marked as duplicate by tripleee
StackExchange.ready(function()
if (StackExchange.options.isMobile) return;
$('.dupe-hammer-message-hover:not(.hover-bound)').each(function()
var $hover = $(this).addClass('hover-bound'),
$msg = $hover.siblings('.dupe-hammer-message');
$hover.hover(
function()
$hover.showInfoMessage('',
messageElement: $msg.clone().show(),
transient: false,
position: my: 'bottom left', at: 'top center', offsetTop: -7 ,
dismissable: false,
relativeToBody: true
);
,
function()
StackExchange.helpers.removeMessages();
);
);
);
Mar 8 at 13:26
This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.
add a comment |
This question already has an answer here:
Preserve Quotes in bash arguments
3 answers
As passing arguments to a self made script, I noted they got evaluated by the file-system if that mach, otherwise, just passed as argument. And that is not the behaviour I'm hopping for
giving that code
#!/bin/bash
declare -a array_arg
#build the array of arguments
while test -n "$1"; do array_arg+=( "$1" ); shift
done
#test there is some arguments
if test $#array_arg[@] -eq 0; then echo "ERROR no arguments"
fi
#running resume
echo "number of elements:: $#array_arg[@]"
for ((i = 0; i < $#array_arg[@]; i++ )); do echo "$i>> $array_arg[i]"
done
I will expect that same list of arguments I pass, I will have into the array_arg array
but, if any argument has a wildcard, and match a file, it get resolve with the name of the file/s
lets see an example :
let's observe, the second argument
file2*
how in the instruction
array_arg+=( "$1" )
adds two filenames to the array, instead of the value of $1
while the last argument, do not get changed/resolved/whatever...
Needless to say, I need the arguments as passed to the script, not evaluated
linux bash shell ubuntu
marked as duplicate by tripleee
StackExchange.ready(function()
if (StackExchange.options.isMobile) return;
$('.dupe-hammer-message-hover:not(.hover-bound)').each(function()
var $hover = $(this).addClass('hover-bound'),
$msg = $hover.siblings('.dupe-hammer-message');
$hover.hover(
function()
$hover.showInfoMessage('',
messageElement: $msg.clone().show(),
transient: false,
position: my: 'bottom left', at: 'top center', offsetTop: -7 ,
dismissable: false,
relativeToBody: true
);
,
function()
StackExchange.helpers.removeMessages();
);
);
);
Mar 8 at 13:26
This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.
2
If you don't want the sell to expand your arguments, quote them.
– Poshi
Mar 8 at 13:13
add a comment |
This question already has an answer here:
Preserve Quotes in bash arguments
3 answers
As passing arguments to a self made script, I noted they got evaluated by the file-system if that mach, otherwise, just passed as argument. And that is not the behaviour I'm hopping for
giving that code
#!/bin/bash
declare -a array_arg
#build the array of arguments
while test -n "$1"; do array_arg+=( "$1" ); shift
done
#test there is some arguments
if test $#array_arg[@] -eq 0; then echo "ERROR no arguments"
fi
#running resume
echo "number of elements:: $#array_arg[@]"
for ((i = 0; i < $#array_arg[@]; i++ )); do echo "$i>> $array_arg[i]"
done
I will expect that same list of arguments I pass, I will have into the array_arg array
but, if any argument has a wildcard, and match a file, it get resolve with the name of the file/s
lets see an example :
let's observe, the second argument
file2*
how in the instruction
array_arg+=( "$1" )
adds two filenames to the array, instead of the value of $1
while the last argument, do not get changed/resolved/whatever...
Needless to say, I need the arguments as passed to the script, not evaluated
linux bash shell ubuntu
This question already has an answer here:
Preserve Quotes in bash arguments
3 answers
As passing arguments to a self made script, I noted they got evaluated by the file-system if that mach, otherwise, just passed as argument. And that is not the behaviour I'm hopping for
giving that code
#!/bin/bash
declare -a array_arg
#build the array of arguments
while test -n "$1"; do array_arg+=( "$1" ); shift
done
#test there is some arguments
if test $#array_arg[@] -eq 0; then echo "ERROR no arguments"
fi
#running resume
echo "number of elements:: $#array_arg[@]"
for ((i = 0; i < $#array_arg[@]; i++ )); do echo "$i>> $array_arg[i]"
done
I will expect that same list of arguments I pass, I will have into the array_arg array
but, if any argument has a wildcard, and match a file, it get resolve with the name of the file/s
lets see an example :
let's observe, the second argument
file2*
how in the instruction
array_arg+=( "$1" )
adds two filenames to the array, instead of the value of $1
while the last argument, do not get changed/resolved/whatever...
Needless to say, I need the arguments as passed to the script, not evaluated
This question already has an answer here:
Preserve Quotes in bash arguments
3 answers
linux bash shell ubuntu
linux bash shell ubuntu
asked Mar 8 at 13:11
pGrnd2pGrnd2
134110
134110
marked as duplicate by tripleee
StackExchange.ready(function()
if (StackExchange.options.isMobile) return;
$('.dupe-hammer-message-hover:not(.hover-bound)').each(function()
var $hover = $(this).addClass('hover-bound'),
$msg = $hover.siblings('.dupe-hammer-message');
$hover.hover(
function()
$hover.showInfoMessage('',
messageElement: $msg.clone().show(),
transient: false,
position: my: 'bottom left', at: 'top center', offsetTop: -7 ,
dismissable: false,
relativeToBody: true
);
,
function()
StackExchange.helpers.removeMessages();
);
);
);
Mar 8 at 13:26
This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.
marked as duplicate by tripleee
StackExchange.ready(function()
if (StackExchange.options.isMobile) return;
$('.dupe-hammer-message-hover:not(.hover-bound)').each(function()
var $hover = $(this).addClass('hover-bound'),
$msg = $hover.siblings('.dupe-hammer-message');
$hover.hover(
function()
$hover.showInfoMessage('',
messageElement: $msg.clone().show(),
transient: false,
position: my: 'bottom left', at: 'top center', offsetTop: -7 ,
dismissable: false,
relativeToBody: true
);
,
function()
StackExchange.helpers.removeMessages();
);
);
);
Mar 8 at 13:26
This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.
2
If you don't want the sell to expand your arguments, quote them.
– Poshi
Mar 8 at 13:13
add a comment |
2
If you don't want the sell to expand your arguments, quote them.
– Poshi
Mar 8 at 13:13
2
2
If you don't want the sell to expand your arguments, quote them.
– Poshi
Mar 8 at 13:13
If you don't want the sell to expand your arguments, quote them.
– Poshi
Mar 8 at 13:13
add a comment |
1 Answer
1
active
oldest
votes
./test.sh "file1" "file2" "file3"
This will run fine.
add a comment |
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
./test.sh "file1" "file2" "file3"
This will run fine.
add a comment |
./test.sh "file1" "file2" "file3"
This will run fine.
add a comment |
./test.sh "file1" "file2" "file3"
This will run fine.
./test.sh "file1" "file2" "file3"
This will run fine.
answered Mar 8 at 13:23
BllackjackBllackjack
592
592
add a comment |
add a comment |
2
If you don't want the sell to expand your arguments, quote them.
– Poshi
Mar 8 at 13:13