Why are backslashes included in this shell script?Run a command that is shadowed by an aliasWhy escape trivial characters in shell script?Is there any reason to escape a dot in a bash filename expansion?How do you use variables with values containing spaces in a Z-shell (zsh) script command?Why does commenting out this line in a shell script (using pdftk) cause problems?log out via shell scriptIs there a function in shell script equivalent a var_dump(PHP)Why does number of backslashes increase in strace as opposed to being reduced by bash rules?What does backslash dot mean as a command?Why does this 'while' loop not recognize the last line?how do i add the creation of a directory to this cli command

Why is it bad to use your whole foot in rock climbing

Are athlete's college degrees discounted by employers and graduate school admissions?

Is Jesus the last Prophet?

How do I type a hyphen in iOS 12?

What does this line mean in Zelazny's The Courts of Chaos?

How to represent jealousy in a cute way?

ISP is not hashing the password I log in with online. Should I take any action?

How to deal with an excess of white-space in a CRM UI?

If absolute velocity does not exist, how can we say a rocket accelerates in empty space?

Which are the methodologies for interpreting Vedas?

Can I get a photo of an Ancient Arrow?

Can a 40amp breaker be used safely and without issue with a 40amp device on 6AWG wire?

What is the language spoken in Babylon?

Keeping track of theme when improvising

Does scarcity apply only to commodities?

The best in flight meal option for those suffering from reflux

In American Politics, why is the Justice Department under the President?

Did I need a visa in 2004 and 2006?

Is the first of the 10 Commandments considered a mitzvah?

What do you call the action of "describing events as they happen" like sports anchors do?

A life of PhD: is it feasible?

In The Incredibles 2, why does Screenslaver's name use a pun on something that doesn't exist in the 1950s pastiche?

Am I being scammed by a sugar daddy?

Does the UK delegate some immigration control to the Republic of Ireland?



Why are backslashes included in this shell script?


Run a command that is shadowed by an aliasWhy escape trivial characters in shell script?Is there any reason to escape a dot in a bash filename expansion?How do you use variables with values containing spaces in a Z-shell (zsh) script command?Why does commenting out this line in a shell script (using pdftk) cause problems?log out via shell scriptIs there a function in shell script equivalent a var_dump(PHP)Why does number of backslashes increase in strace as opposed to being reduced by bash rules?What does backslash dot mean as a command?Why does this 'while' loop not recognize the last line?how do i add the creation of a directory to this cli command






.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;








2















In my copy of the conda.sh script, I see the following lines:



if [ -n "$_CE_CONDA" ] && [ -n "$WINDIR+x" ]; then
SYSP=$(dirname "$CONDA_EXE")
else
SYSP=$(dirname "$CONDA_EXE")
SYSP=$(dirname "$SYSP")
fi


I am curious as to why there is a backslash in front the the d in dirname. I do not believe it is necessary. This use of backslashes also appears in other places in the source file. Is there a reason for doing this that I am missing?










share|improve this question

















  • 1





    Related: Run a command that is shadowed by an alias

    – steeldriver
    7 hours ago

















2















In my copy of the conda.sh script, I see the following lines:



if [ -n "$_CE_CONDA" ] && [ -n "$WINDIR+x" ]; then
SYSP=$(dirname "$CONDA_EXE")
else
SYSP=$(dirname "$CONDA_EXE")
SYSP=$(dirname "$SYSP")
fi


I am curious as to why there is a backslash in front the the d in dirname. I do not believe it is necessary. This use of backslashes also appears in other places in the source file. Is there a reason for doing this that I am missing?










share|improve this question

















  • 1





    Related: Run a command that is shadowed by an alias

    – steeldriver
    7 hours ago













2












2








2


1






In my copy of the conda.sh script, I see the following lines:



if [ -n "$_CE_CONDA" ] && [ -n "$WINDIR+x" ]; then
SYSP=$(dirname "$CONDA_EXE")
else
SYSP=$(dirname "$CONDA_EXE")
SYSP=$(dirname "$SYSP")
fi


I am curious as to why there is a backslash in front the the d in dirname. I do not believe it is necessary. This use of backslashes also appears in other places in the source file. Is there a reason for doing this that I am missing?










share|improve this question














In my copy of the conda.sh script, I see the following lines:



if [ -n "$_CE_CONDA" ] && [ -n "$WINDIR+x" ]; then
SYSP=$(dirname "$CONDA_EXE")
else
SYSP=$(dirname "$CONDA_EXE")
SYSP=$(dirname "$SYSP")
fi


I am curious as to why there is a backslash in front the the d in dirname. I do not believe it is necessary. This use of backslashes also appears in other places in the source file. Is there a reason for doing this that I am missing?







bash shell-script






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked 8 hours ago









extremeaxe5extremeaxe5

26618




26618







  • 1





    Related: Run a command that is shadowed by an alias

    – steeldriver
    7 hours ago












  • 1





    Related: Run a command that is shadowed by an alias

    – steeldriver
    7 hours ago







1




1





Related: Run a command that is shadowed by an alias

– steeldriver
7 hours ago





Related: Run a command that is shadowed by an alias

– steeldriver
7 hours ago










2 Answers
2






active

oldest

votes


















7














If conda.sh is a file meant to be sourced, then the backslashes are for bypassing aliases. Bash typically disables alias expansion for script execution, but for sourced files, which may run in interactive shells, that's not the case. So just dirname may run an alias named dirname, but dirname will skip alias expansion and run a function or command named dirname. (Not just backslashes, though, any quoting will do.)






share|improve this answer


















  • 1





    Or command dirname.

    – Kusalananda
    8 hours ago


















4














Backslash will suppress alias expansion, ie it executes the original command and makes sure that alias version does not run. Scripts can unknowingly run with alias expansion when the system has set shopt -s expand_aliases (BASH only) or if it is executed using source.



./conda.sh # usually no alias expansion (unless `shopt -s expand_aliases` in BASH)
source ./conda.sh # alias expansion
. ./conda.sh # alias expansion


Some sysadmins like to put backslash in everything as a preventive measure against side-effects of aliases, just in case it was aliased unintentionally somewhere else and the alias gets expanded as explained previously. For example, if the system has set this alias dirname='dirname -z' somewhere and the condition allows the alias to be expanded, then a script that tries to call dirname will unfortunately call dirname -z instead, which was not the script intended.



If there's certainty that such alias do not exist, we can remove all the backslash and it should work fine.



Alternatively, one can use command instead of backslash version to suppress alias. Thus, instead of dirname, one can use command dirname, which might look more readable. (For built-in commands like cd, one should use builtin instead). I prefer this instead, as it also bypasses function with same name as well as any aliases.






share|improve this answer























    Your Answer








    StackExchange.ready(function()
    var channelOptions =
    tags: "".split(" "),
    id: "106"
    ;
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function()
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled)
    StackExchange.using("snippets", function()
    createEditor();
    );

    else
    createEditor();

    );

    function createEditor()
    StackExchange.prepareEditor(
    heartbeatType: 'answer',
    autoActivateHeartbeat: false,
    convertImagesToLinks: false,
    noModals: true,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: null,
    bindNavPrevention: true,
    postfix: "",
    imageUploader:
    brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
    contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
    allowUrls: true
    ,
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    );



    );













    draft saved

    draft discarded


















    StackExchange.ready(
    function ()
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f524254%2fwhy-are-backslashes-included-in-this-shell-script%23new-answer', 'question_page');

    );

    Post as a guest















    Required, but never shown

























    2 Answers
    2






    active

    oldest

    votes








    2 Answers
    2






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes









    7














    If conda.sh is a file meant to be sourced, then the backslashes are for bypassing aliases. Bash typically disables alias expansion for script execution, but for sourced files, which may run in interactive shells, that's not the case. So just dirname may run an alias named dirname, but dirname will skip alias expansion and run a function or command named dirname. (Not just backslashes, though, any quoting will do.)






    share|improve this answer


















    • 1





      Or command dirname.

      – Kusalananda
      8 hours ago















    7














    If conda.sh is a file meant to be sourced, then the backslashes are for bypassing aliases. Bash typically disables alias expansion for script execution, but for sourced files, which may run in interactive shells, that's not the case. So just dirname may run an alias named dirname, but dirname will skip alias expansion and run a function or command named dirname. (Not just backslashes, though, any quoting will do.)






    share|improve this answer


















    • 1





      Or command dirname.

      – Kusalananda
      8 hours ago













    7












    7








    7







    If conda.sh is a file meant to be sourced, then the backslashes are for bypassing aliases. Bash typically disables alias expansion for script execution, but for sourced files, which may run in interactive shells, that's not the case. So just dirname may run an alias named dirname, but dirname will skip alias expansion and run a function or command named dirname. (Not just backslashes, though, any quoting will do.)






    share|improve this answer













    If conda.sh is a file meant to be sourced, then the backslashes are for bypassing aliases. Bash typically disables alias expansion for script execution, but for sourced files, which may run in interactive shells, that's not the case. So just dirname may run an alias named dirname, but dirname will skip alias expansion and run a function or command named dirname. (Not just backslashes, though, any quoting will do.)







    share|improve this answer












    share|improve this answer



    share|improve this answer










    answered 8 hours ago









    murumuru

    39.3k595170




    39.3k595170







    • 1





      Or command dirname.

      – Kusalananda
      8 hours ago












    • 1





      Or command dirname.

      – Kusalananda
      8 hours ago







    1




    1





    Or command dirname.

    – Kusalananda
    8 hours ago





    Or command dirname.

    – Kusalananda
    8 hours ago













    4














    Backslash will suppress alias expansion, ie it executes the original command and makes sure that alias version does not run. Scripts can unknowingly run with alias expansion when the system has set shopt -s expand_aliases (BASH only) or if it is executed using source.



    ./conda.sh # usually no alias expansion (unless `shopt -s expand_aliases` in BASH)
    source ./conda.sh # alias expansion
    . ./conda.sh # alias expansion


    Some sysadmins like to put backslash in everything as a preventive measure against side-effects of aliases, just in case it was aliased unintentionally somewhere else and the alias gets expanded as explained previously. For example, if the system has set this alias dirname='dirname -z' somewhere and the condition allows the alias to be expanded, then a script that tries to call dirname will unfortunately call dirname -z instead, which was not the script intended.



    If there's certainty that such alias do not exist, we can remove all the backslash and it should work fine.



    Alternatively, one can use command instead of backslash version to suppress alias. Thus, instead of dirname, one can use command dirname, which might look more readable. (For built-in commands like cd, one should use builtin instead). I prefer this instead, as it also bypasses function with same name as well as any aliases.






    share|improve this answer



























      4














      Backslash will suppress alias expansion, ie it executes the original command and makes sure that alias version does not run. Scripts can unknowingly run with alias expansion when the system has set shopt -s expand_aliases (BASH only) or if it is executed using source.



      ./conda.sh # usually no alias expansion (unless `shopt -s expand_aliases` in BASH)
      source ./conda.sh # alias expansion
      . ./conda.sh # alias expansion


      Some sysadmins like to put backslash in everything as a preventive measure against side-effects of aliases, just in case it was aliased unintentionally somewhere else and the alias gets expanded as explained previously. For example, if the system has set this alias dirname='dirname -z' somewhere and the condition allows the alias to be expanded, then a script that tries to call dirname will unfortunately call dirname -z instead, which was not the script intended.



      If there's certainty that such alias do not exist, we can remove all the backslash and it should work fine.



      Alternatively, one can use command instead of backslash version to suppress alias. Thus, instead of dirname, one can use command dirname, which might look more readable. (For built-in commands like cd, one should use builtin instead). I prefer this instead, as it also bypasses function with same name as well as any aliases.






      share|improve this answer

























        4












        4








        4







        Backslash will suppress alias expansion, ie it executes the original command and makes sure that alias version does not run. Scripts can unknowingly run with alias expansion when the system has set shopt -s expand_aliases (BASH only) or if it is executed using source.



        ./conda.sh # usually no alias expansion (unless `shopt -s expand_aliases` in BASH)
        source ./conda.sh # alias expansion
        . ./conda.sh # alias expansion


        Some sysadmins like to put backslash in everything as a preventive measure against side-effects of aliases, just in case it was aliased unintentionally somewhere else and the alias gets expanded as explained previously. For example, if the system has set this alias dirname='dirname -z' somewhere and the condition allows the alias to be expanded, then a script that tries to call dirname will unfortunately call dirname -z instead, which was not the script intended.



        If there's certainty that such alias do not exist, we can remove all the backslash and it should work fine.



        Alternatively, one can use command instead of backslash version to suppress alias. Thus, instead of dirname, one can use command dirname, which might look more readable. (For built-in commands like cd, one should use builtin instead). I prefer this instead, as it also bypasses function with same name as well as any aliases.






        share|improve this answer













        Backslash will suppress alias expansion, ie it executes the original command and makes sure that alias version does not run. Scripts can unknowingly run with alias expansion when the system has set shopt -s expand_aliases (BASH only) or if it is executed using source.



        ./conda.sh # usually no alias expansion (unless `shopt -s expand_aliases` in BASH)
        source ./conda.sh # alias expansion
        . ./conda.sh # alias expansion


        Some sysadmins like to put backslash in everything as a preventive measure against side-effects of aliases, just in case it was aliased unintentionally somewhere else and the alias gets expanded as explained previously. For example, if the system has set this alias dirname='dirname -z' somewhere and the condition allows the alias to be expanded, then a script that tries to call dirname will unfortunately call dirname -z instead, which was not the script intended.



        If there's certainty that such alias do not exist, we can remove all the backslash and it should work fine.



        Alternatively, one can use command instead of backslash version to suppress alias. Thus, instead of dirname, one can use command dirname, which might look more readable. (For built-in commands like cd, one should use builtin instead). I prefer this instead, as it also bypasses function with same name as well as any aliases.







        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered 7 hours ago









        otter.prootter.pro

        513




        513



























            draft saved

            draft discarded
















































            Thanks for contributing an answer to Unix & Linux Stack Exchange!


            • Please be sure to answer the question. Provide details and share your research!

            But avoid


            • Asking for help, clarification, or responding to other answers.

            • Making statements based on opinion; back them up with references or personal experience.

            To learn more, see our tips on writing great answers.




            draft saved


            draft discarded














            StackExchange.ready(
            function ()
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f524254%2fwhy-are-backslashes-included-in-this-shell-script%23new-answer', 'question_page');

            );

            Post as a guest















            Required, but never shown





















































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown

































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown







            Popular posts from this blog

            Invision Community Contents History See also References External links Navigation menuProprietaryinvisioncommunity.comIPS Community ForumsIPS Community Forumsthis blog entry"License Changes, IP.Board 3.4, and the Future""Interview -- Matt Mecham of Ibforums""CEO Invision Power Board, Matt Mecham Is a Liar, Thief!"IPB License Explanation 1.3, 1.3.1, 2.0, and 2.1ArchivedSecurity Fixes, Updates And Enhancements For IPB 1.3.1Archived"New Demo Accounts - Invision Power Services"the original"New Default Skin"the original"Invision Power Board 3.0.0 and Applications Released"the original"Archived copy"the original"Perpetual licenses being done away with""Release Notes - Invision Power Services""Introducing: IPS Community Suite 4!"Invision Community Release Notes

            Canceling a color specificationRandomly assigning color to Graphics3D objects?Default color for Filling in Mathematica 9Coloring specific elements of sets with a prime modified order in an array plotHow to pick a color differing significantly from the colors already in a given color list?Detection of the text colorColor numbers based on their valueCan color schemes for use with ColorData include opacity specification?My dynamic color schemes

            Ласкавець круглолистий Зміст Опис | Поширення | Галерея | Примітки | Посилання | Навігаційне меню58171138361-22960890446Bupleurum rotundifoliumEuro+Med PlantbasePlants of the World Online — Kew ScienceGermplasm Resources Information Network (GRIN)Ласкавецькн. VI : Літери Ком — Левиправивши або дописавши її