How does zsh expand variables before passing to programs?Expanding variables in zshGlobbing with brackets and...

Why do you need to heat the pan before heating the olive oil?

Name for a function whose effect is canceled by another function?

What does it cost to buy a tavern?

"Correct me if I'm wrong"

Counterfeit checks were created for my account. How does this type of fraud work?

How is the idea of "girlfriend material" naturally expressed in Russian?

How to take photos with a yellowish tone and point-and-shoot film camera look?

Large-n limit of the distribution of the normalized sum of Cauchy random variables

How did Frodo know where the Bree village was?

How to compute the inverse of an operation in Q#?

What is the "ls" directory in my home directory?

Is there any possible way to get these hearts as Adult Link?

In the US, can a former president run again?

What is that ceiling compartment of a Boeing 737?

Are there any individual aliens that have gained superpowers in the Marvel universe?

What mathematical theory is required for high frequency trading?

Are there examples of rowers who also fought?

How can I ping multiple IP addresses at the same time?

Time at 1 g acceleration to travel 100 000 light years

How can I prevent a user from copying files on another hard drive?

Can a character learn spells from someone else's spellbook and then sell it?

Justifying Affordable Bespoke Spaceships

How "fast" do astronomical events occur?

Unrecognized IC Package Style



How does zsh expand variables before passing to programs?


Expanding variables in zshGlobbing with brackets and variables in zshzsh - fully expand binary path on <tab>Expand variable in function definition in zshHow can I expand all variables at the command line in Zsh?Expand parameter in quotes in zshOn passing arguments to programs through array variableszsh, expand * to (a|b|c)Why does $((0.1)) expand to 0.10000000000000001 in zsh?Expand alias in ZSH history






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







0















A basic rule of zsh is that you don't need to quote your variables, for example:



% data="single argument"
% print -l $data
single argument


One exception I know of is that if an argument must not be skipped even if empty, it must be double quoted:



% emptyarg=
% functon count() { echo $# }
% count $emptyarg
0
% count "$emptyarg"
1


However, if an argument contains certain special characters, it must be quoted or the shell gives an error. Why is that? It seems fragile. The content of my data shouldn't substantially influence how functions/commands run.










share|improve this question







New contributor



piojo is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.


























    0















    A basic rule of zsh is that you don't need to quote your variables, for example:



    % data="single argument"
    % print -l $data
    single argument


    One exception I know of is that if an argument must not be skipped even if empty, it must be double quoted:



    % emptyarg=
    % functon count() { echo $# }
    % count $emptyarg
    0
    % count "$emptyarg"
    1


    However, if an argument contains certain special characters, it must be quoted or the shell gives an error. Why is that? It seems fragile. The content of my data shouldn't substantially influence how functions/commands run.










    share|improve this question







    New contributor



    piojo is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
    Check out our Code of Conduct.






















      0












      0








      0








      A basic rule of zsh is that you don't need to quote your variables, for example:



      % data="single argument"
      % print -l $data
      single argument


      One exception I know of is that if an argument must not be skipped even if empty, it must be double quoted:



      % emptyarg=
      % functon count() { echo $# }
      % count $emptyarg
      0
      % count "$emptyarg"
      1


      However, if an argument contains certain special characters, it must be quoted or the shell gives an error. Why is that? It seems fragile. The content of my data shouldn't substantially influence how functions/commands run.










      share|improve this question







      New contributor



      piojo is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.











      A basic rule of zsh is that you don't need to quote your variables, for example:



      % data="single argument"
      % print -l $data
      single argument


      One exception I know of is that if an argument must not be skipped even if empty, it must be double quoted:



      % emptyarg=
      % functon count() { echo $# }
      % count $emptyarg
      0
      % count "$emptyarg"
      1


      However, if an argument contains certain special characters, it must be quoted or the shell gives an error. Why is that? It seems fragile. The content of my data shouldn't substantially influence how functions/commands run.







      zsh parameter






      share|improve this question







      New contributor



      piojo is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.










      share|improve this question







      New contributor



      piojo is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.








      share|improve this question




      share|improve this question






      New contributor



      piojo is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.








      asked 1 hour ago









      piojopiojo

      1011




      1011




      New contributor



      piojo is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.




      New contributor




      piojo is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.
























          1 Answer
          1






          active

          oldest

          votes


















          0














          I noticed the behavior works as expected in scripts (parameters don't expand, even without quotes). I realized the issue was probably caused by an option, so I ran setopt in my interactive shell and in a script and compared the results. I turned them off one by one until I found setopt noglobsubst had the desired effect. In short, the GLOB_SUBST option makes zsh treat all variables as patterns to be expanded if possible. You can disable this option and still expand variables when needed with the tilde ~ parameter expansion:



          % setopt noglobsubst
          % star=*
          % echo $star
          *
          % echo $~star
          readme.txt test.sh





          share|improve this answer








          New contributor



          piojo is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
          Check out our Code of Conduct.




















          • is the globsubst option on by default?

            – Uncle Billy
            54 mins ago












          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
          });


          }
          });






          piojo is a new contributor. Be nice, and check out our Code of Conduct.










          draft saved

          draft discarded


















          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f525337%2fhow-does-zsh-expand-variables-before-passing-to-programs%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown

























          1 Answer
          1






          active

          oldest

          votes








          1 Answer
          1






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes









          0














          I noticed the behavior works as expected in scripts (parameters don't expand, even without quotes). I realized the issue was probably caused by an option, so I ran setopt in my interactive shell and in a script and compared the results. I turned them off one by one until I found setopt noglobsubst had the desired effect. In short, the GLOB_SUBST option makes zsh treat all variables as patterns to be expanded if possible. You can disable this option and still expand variables when needed with the tilde ~ parameter expansion:



          % setopt noglobsubst
          % star=*
          % echo $star
          *
          % echo $~star
          readme.txt test.sh





          share|improve this answer








          New contributor



          piojo is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
          Check out our Code of Conduct.




















          • is the globsubst option on by default?

            – Uncle Billy
            54 mins ago
















          0














          I noticed the behavior works as expected in scripts (parameters don't expand, even without quotes). I realized the issue was probably caused by an option, so I ran setopt in my interactive shell and in a script and compared the results. I turned them off one by one until I found setopt noglobsubst had the desired effect. In short, the GLOB_SUBST option makes zsh treat all variables as patterns to be expanded if possible. You can disable this option and still expand variables when needed with the tilde ~ parameter expansion:



          % setopt noglobsubst
          % star=*
          % echo $star
          *
          % echo $~star
          readme.txt test.sh





          share|improve this answer








          New contributor



          piojo is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
          Check out our Code of Conduct.




















          • is the globsubst option on by default?

            – Uncle Billy
            54 mins ago














          0












          0








          0







          I noticed the behavior works as expected in scripts (parameters don't expand, even without quotes). I realized the issue was probably caused by an option, so I ran setopt in my interactive shell and in a script and compared the results. I turned them off one by one until I found setopt noglobsubst had the desired effect. In short, the GLOB_SUBST option makes zsh treat all variables as patterns to be expanded if possible. You can disable this option and still expand variables when needed with the tilde ~ parameter expansion:



          % setopt noglobsubst
          % star=*
          % echo $star
          *
          % echo $~star
          readme.txt test.sh





          share|improve this answer








          New contributor



          piojo is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
          Check out our Code of Conduct.









          I noticed the behavior works as expected in scripts (parameters don't expand, even without quotes). I realized the issue was probably caused by an option, so I ran setopt in my interactive shell and in a script and compared the results. I turned them off one by one until I found setopt noglobsubst had the desired effect. In short, the GLOB_SUBST option makes zsh treat all variables as patterns to be expanded if possible. You can disable this option and still expand variables when needed with the tilde ~ parameter expansion:



          % setopt noglobsubst
          % star=*
          % echo $star
          *
          % echo $~star
          readme.txt test.sh






          share|improve this answer








          New contributor



          piojo is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
          Check out our Code of Conduct.








          share|improve this answer



          share|improve this answer






          New contributor



          piojo is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
          Check out our Code of Conduct.








          answered 1 hour ago









          piojopiojo

          1011




          1011




          New contributor



          piojo is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
          Check out our Code of Conduct.




          New contributor




          piojo is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
          Check out our Code of Conduct.















          • is the globsubst option on by default?

            – Uncle Billy
            54 mins ago



















          • is the globsubst option on by default?

            – Uncle Billy
            54 mins ago

















          is the globsubst option on by default?

          – Uncle Billy
          54 mins ago





          is the globsubst option on by default?

          – Uncle Billy
          54 mins ago










          piojo is a new contributor. Be nice, and check out our Code of Conduct.










          draft saved

          draft discarded


















          piojo is a new contributor. Be nice, and check out our Code of Conduct.













          piojo is a new contributor. Be nice, and check out our Code of Conduct.












          piojo is a new contributor. Be nice, and check out our Code of Conduct.
















          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%2f525337%2fhow-does-zsh-expand-variables-before-passing-to-programs%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

          Taj Mahal Inhaltsverzeichnis Aufbau | Geschichte | 350-Jahr-Feier | Heutige Bedeutung | Siehe auch |...

          Baia Sprie Cuprins Etimologie | Istorie | Demografie | Politică și administrație | Arii naturale...

          Ciclooctatetraenă Vezi și | Bibliografie | Meniu de navigare637866text4148569-500570979m