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
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
add a comment |
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
add a comment |
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
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
powershell syntax command-line-arguments
edited Mar 6 at 13:42
mklement0
134k21251288
134k21251288
asked Mar 6 at 13:25
deostrolldeostroll
6,4191771133
6,4191771133
add a comment |
add a comment |
1 Answer
1
active
oldest
votes
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.
add a comment |
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
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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
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.
add a comment |
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.
add a comment |
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.
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.
edited Mar 6 at 13:40
answered Mar 6 at 13:27
mklement0mklement0
134k21251288
134k21251288
add a comment |
add a comment |
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.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
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