passing exclamation, brackets as part of executable arguments in powershell2019 Community Moderator ElectionSetting Public Property Values on the Command LineExecute PowerShell Script from C# with Commandline ArgumentsSetting Windows PowerShell path variableHow to pass command line arguments to a rake taskHow to redirect the output of a PowerShell to a file during its executionHow to run a PowerShell scriptHow to handle command-line arguments in PowerShellPowerShell says “execution of scripts is disabled on this system.”How do I pass command line arguments to a Node.js program?How to pass an argument to a PowerShell script?How to make PowerShell tab completion work like Bash

How to install round brake pads

How do you make a gun that shoots melee weapons and/or swords?

How should I solve this integral with changing parameters?

What is better: yes / no radio, or simple checkbox?

Is it possible to clone a polymorphic object without manually adding overridden clone method into each derived class in C++?

Cycles on the torus

Is there stress on two letters on the word стоят

If nine coins are tossed, what is the probability that the number of heads is even?

Would those living in a "perfect society" not understand satire

What was so special about The Piano that Ada was willing to do anything to have it?

Has a sovereign Communist government ever run, and conceded loss, on a fair election?

How can I portion out frozen cookie dough?

Writing text next to a table

Either of .... (Plural/Singular)

Why is there an extra space when I type "ls" on the Desktop?

What is the purpose of a disclaimer like "this is not legal advice"?

-1 to the power of a irrational number

How do I increase the number of TTY consoles?

School performs periodic password audits. Is my password compromised?

What would be the most expensive material to an intergalactic society?

When to use a QR code on a business card?

Computation logic of Partway in TikZ

Sampling from Gaussian mixture models, when are the sampled data independent?

What happened to the colonial estates belonging to loyalists after the American Revolution?



passing exclamation, brackets as part of executable arguments in powershell



2019 Community Moderator ElectionSetting Public Property Values on the Command LineExecute PowerShell Script from C# with Commandline ArgumentsSetting Windows PowerShell path variableHow to pass command line arguments to a rake taskHow to redirect the output of a PowerShell to a file during its executionHow to run a PowerShell scriptHow to handle command-line arguments in PowerShellPowerShell says “execution of scripts is disabled on this system.”How do I pass command line arguments to a Node.js program?How to pass an argument to a PowerShell script?How to make PowerShell tab completion work like Bash










1















In git, if we want to exclude a file from diff output (on bash) we do something like follows:



git diff -- !(file.txt)


But this is disallowed in powershell. Hence is there a way to achieve this in the powershell prompt?










share|improve this question




























    1















    In git, if we want to exclude a file from diff output (on bash) we do something like follows:



    git diff -- !(file.txt)


    But this is disallowed in powershell. Hence is there a way to achieve this in the powershell prompt?










    share|improve this question


























      1












      1








      1


      1






      In git, if we want to exclude a file from diff output (on bash) we do something like follows:



      git diff -- !(file.txt)


      But this is disallowed in powershell. Hence is there a way to achieve this in the powershell prompt?










      share|improve this question
















      In git, if we want to exclude a file from diff output (on bash) we do something like follows:



      git diff -- !(file.txt)


      But this is disallowed in powershell. Hence is there a way to achieve this in the powershell prompt?







      powershell syntax command-line-arguments






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Mar 6 at 13:42









      mklement0

      134k21251288




      134k21251288










      asked Mar 6 at 13:25









      deostrolldeostroll

      6,4191771133




      6,4191771133






















          1 Answer
          1






          active

          oldest

          votes


















          1














          Simply single-quote your argument:



          git diff -- '!(file.txt)'


          Single-quoting makes PowerShell treat the string literally and prevents it from interpreting chars. such as ( as its own metacharacters.



          Before invoking the target program, PowerShell re-quotes arguments if and as needed, behind the scenes; that is:



          • It encloses an argument in "..." if it contains whitespace, and also in certain, less common scenarios (see link below).


          • It passes it without quotes otherwise.


          Note: There are pitfalls associated with this invisible re-quoting - see this answer.






          share|improve this answer
























            Your Answer






            StackExchange.ifUsing("editor", function ()
            StackExchange.using("externalEditor", function ()
            StackExchange.using("snippets", function ()
            StackExchange.snippets.init();
            );
            );
            , "code-snippets");

            StackExchange.ready(function()
            var channelOptions =
            tags: "".split(" "),
            id: "1"
            ;
            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: true,
            noModals: true,
            showLowRepImageUploadWarning: true,
            reputationToPostImages: 10,
            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%2fstackoverflow.com%2fquestions%2f55024208%2fpassing-exclamation-brackets-as-part-of-executable-arguments-in-powershell%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









            1














            Simply single-quote your argument:



            git diff -- '!(file.txt)'


            Single-quoting makes PowerShell treat the string literally and prevents it from interpreting chars. such as ( as its own metacharacters.



            Before invoking the target program, PowerShell re-quotes arguments if and as needed, behind the scenes; that is:



            • It encloses an argument in "..." if it contains whitespace, and also in certain, less common scenarios (see link below).


            • It passes it without quotes otherwise.


            Note: There are pitfalls associated with this invisible re-quoting - see this answer.






            share|improve this answer





























              1














              Simply single-quote your argument:



              git diff -- '!(file.txt)'


              Single-quoting makes PowerShell treat the string literally and prevents it from interpreting chars. such as ( as its own metacharacters.



              Before invoking the target program, PowerShell re-quotes arguments if and as needed, behind the scenes; that is:



              • It encloses an argument in "..." if it contains whitespace, and also in certain, less common scenarios (see link below).


              • It passes it without quotes otherwise.


              Note: There are pitfalls associated with this invisible re-quoting - see this answer.






              share|improve this answer



























                1












                1








                1







                Simply single-quote your argument:



                git diff -- '!(file.txt)'


                Single-quoting makes PowerShell treat the string literally and prevents it from interpreting chars. such as ( as its own metacharacters.



                Before invoking the target program, PowerShell re-quotes arguments if and as needed, behind the scenes; that is:



                • It encloses an argument in "..." if it contains whitespace, and also in certain, less common scenarios (see link below).


                • It passes it without quotes otherwise.


                Note: There are pitfalls associated with this invisible re-quoting - see this answer.






                share|improve this answer















                Simply single-quote your argument:



                git diff -- '!(file.txt)'


                Single-quoting makes PowerShell treat the string literally and prevents it from interpreting chars. such as ( as its own metacharacters.



                Before invoking the target program, PowerShell re-quotes arguments if and as needed, behind the scenes; that is:



                • It encloses an argument in "..." if it contains whitespace, and also in certain, less common scenarios (see link below).


                • It passes it without quotes otherwise.


                Note: There are pitfalls associated with this invisible re-quoting - see this answer.







                share|improve this answer














                share|improve this answer



                share|improve this answer








                edited Mar 6 at 13:40

























                answered Mar 6 at 13:27









                mklement0mklement0

                134k21251288




                134k21251288





























                    draft saved

                    draft discarded
















































                    Thanks for contributing an answer to Stack Overflow!


                    • 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%2fstackoverflow.com%2fquestions%2f55024208%2fpassing-exclamation-brackets-as-part-of-executable-arguments-in-powershell%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

                    1928 у кіно

                    Захаров Федір Захарович

                    Ель Греко