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

            Can't initialize raids on a new ASUS Prime B360M-A motherboard2019 Community Moderator ElectionSimilar to RAID config yet more like mirroring solution?Can't get motherboard serial numberWhy does the BIOS entry point start with a WBINVD instruction?UEFI performance Asus Maximus V Extreme

            Identity Server 4 is not redirecting to Angular app after login2019 Community Moderator ElectionIdentity Server 4 and dockerIdentityserver implicit flow unauthorized_clientIdentityServer Hybrid Flow - Access Token is null after user successful loginIdentity Server to MVC client : Page Redirect After loginLogin with Steam OpenId(oidc-client-js)Identity Server 4+.NET Core 2.0 + IdentityIdentityServer4 post-login redirect not working in Edge browserCall to IdentityServer4 generates System.NullReferenceException: Object reference not set to an instance of an objectIdentityServer4 without HTTPS not workingHow to get Authorization code from identity server without login form

            2005 Ahvaz unrest Contents Background Causes Casualties Aftermath See also References Navigation menue"At Least 10 Are Killed by Bombs in Iran""Iran"Archived"Arab-Iranians in Iran to make April 15 'Day of Fury'"State of Mind, State of Order: Reactions to Ethnic Unrest in the Islamic Republic of Iran.10.1111/j.1754-9469.2008.00028.x"Iran hangs Arab separatists"Iran Overview from ArchivedConstitution of the Islamic Republic of Iran"Tehran puzzled by forged 'riots' letter""Iran and its minorities: Down in the second class""Iran: Handling Of Ahvaz Unrest Could End With Televised Confessions""Bombings Rock Iran Ahead of Election""Five die in Iran ethnic clashes""Iran: Need for restraint as anniversary of unrest in Khuzestan approaches"Archived"Iranian Sunni protesters killed in clashes with security forces"Archived