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?










-1
















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 :



enter image description here



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










share|improve this question













marked as duplicate by tripleee bash
Users with the  bash badge can single-handedly close bash questions as duplicates and reopen them as needed.

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















-1
















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 :



enter image description here



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










share|improve this question













marked as duplicate by tripleee bash
Users with the  bash badge can single-handedly close bash questions as duplicates and reopen them as needed.

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













-1












-1








-1









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 :



enter image description here



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










share|improve this question















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 :



enter image description here



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






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Mar 8 at 13:11









pGrnd2pGrnd2

134110




134110




marked as duplicate by tripleee bash
Users with the  bash badge can single-handedly close bash questions as duplicates and reopen them as needed.

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 bash
Users with the  bash badge can single-handedly close bash questions as duplicates and reopen them as needed.

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












  • 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












1 Answer
1






active

oldest

votes


















0














./test.sh "file1" "file2" "file3"


This will run fine.






share|improve this answer





























    1 Answer
    1






    active

    oldest

    votes








    1 Answer
    1






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes









    0














    ./test.sh "file1" "file2" "file3"


    This will run fine.






    share|improve this answer



























      0














      ./test.sh "file1" "file2" "file3"


      This will run fine.






      share|improve this answer

























        0












        0








        0







        ./test.sh "file1" "file2" "file3"


        This will run fine.






        share|improve this answer













        ./test.sh "file1" "file2" "file3"


        This will run fine.







        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Mar 8 at 13:23









        BllackjackBllackjack

        592




        592















            Popular posts from this blog

            Thal And Out Agency railway station See also References External links Navigation menuOfficial Web Site of Pakistan RailwaysArchivedOfficial Web Site of Pakistan Railwayseeexpanding ite

            Understanding generators in Python2019 Community Moderator ElectionGenerator function not working pythonFor loop not executing two timesGenerators - Printing generated valuesWhy can a python generator only be used once?What exactly do generators do?What does the “yield” keyword do?What does “list comprehension” mean? How does it work and how can I use it?sklearn Kfold acces single fold instead of for loopIs a generator the callable? Which is the generator?Apply Border To Range Of Cells Using OpenpyxlCalling an external command in PythonWhat are metaclasses in Python?What is the difference between @staticmethod and @classmethod?Finding the index of an item given a list containing it in PythonDifference between append vs. extend list methods in PythonHow can I safely create a nested directory in Python?Does Python have a ternary conditional operator?Understanding slice notationUnderstanding Python super() with __init__() methodsDoes Python have a string 'contains' substring method?

            How can I change the color of pagination dots of UIPageControl?How to change UIPageControl dotsIs there a way to change page indicator dots colorCustomize dot with image of UIPageControl at index 0 of UIPageControlNo visible @interface for 'NSObject<PageControlDelegate>' declares the selector 'pageControlPageDidChange:'How to change the color of pagination dots in UIPageControl with a different color per pagepagecontrol indicator custom image instead of DefaultChanging the colour of UIPageControl dots in MonoTouchpagecontrol selectable page visibility color?Alternative way to load ViewControllers on a UIPageControlHow to set only layer.border-color for UIpage control dots in swiftHow can I develop for iPhone using a Windows development machine?How to change the name of an iOS app?UITableView - change section header coloruipagecontrol indicator(dot)issueCustom UIPageControl dots color not changingchange the interspace between UIPageControl dotsHow to change Status Bar text color in iOSHow can I change image tintColor in iOS and WatchKitUIPageControl dots with larger space in between each dotsHow to change the color of pagination dots in UIPageControl with a different color per page