Skip to content

Conversation

@GalaxySnail
Copy link

Description

Support spaces in extract_dir.

Motivation and Context

Fix #6372

How Has This Been Tested?

I tested it locally.

Checklist:

  • I have read the Contributing Guide.
  • I have ensured that I am targeting the develop branch.
  • I have updated the documentation accordingly.
  • I have updated the tests accordingly.
  • I have added an entry in the CHANGELOG.

@o-l-a-v
Copy link
Contributor

o-l-a-v commented Oct 13, 2025

Shouldn't one put the actual path into quotes? Do something like this instead:

$ArgList += '-ir!"{0}\*"' -f $ExtractDir

Vs. what this PR suggests:

$ArgList += '"-ir!$ExtractDir\*"'

^ I also think this will not work, as $variable inside single quote ' will not get the value of the variable.

A string enclosed in single quotation marks is a verbatim string. The string is passed to the command exactly as you type it. No substitution is performed.

@z-Fng
Copy link
Member

z-Fng commented Oct 13, 2025

I also think this will not work, as $variable inside single quote ' will not get the value of the variable.

Yes, a simple test can tell that this doesn't work.

scoop config scoop_repo https://github.com/GalaxySnail/Scoop.git
scoop config scoop_branch quote-extract_dir
scoop update
scoop install https://github.com/ScoopInstaller/Main/raw/0267d4145cdc0ba05fc3f4b5f5532cd682063cca/bucket/highlight.json

@z-Fng
Copy link
Member

z-Fng commented Oct 13, 2025

Double quotes don’t work here either. All existing double quotes will be removed in Invoke-ExternalCommand.

Scoop/lib/core.ps1

Lines 708 to 714 in b588a06

if ($ArgumentList.Length -gt 0) {
# Remove existing double quotes and split arguments
# '(?<=(?<![:\w])[/-]\w+) ' matches a space after a command line switch starting with a slash ('/') or a hyphen ('-')
# The inner item '(?<![:\w])[/-]' matches a slash ('/') or a hyphen ('-') not preceded by a colon (':') or a word character ('\w')
# so that it must be a command line switch, otherwise, it would be a path (e.g. 'C:/Program Files') or other word (e.g. 'some-arg')
# ' (?=[/-])' matches a space followed by a slash ('/') or a hyphen ('-'), i.e. the space before a command line switch
$ArgumentList = $ArgumentList.ForEach({ $_ -replace '"' -split '(?<=(?<![:\w])[/-]\w+) | (?=[/-])' })

@GalaxySnail
Copy link
Author

^ I also think this will not work, as $variable inside single quote ' will not get the value of the variable.

A string enclosed in single quotation marks is a verbatim string. The string is passed to the command exactly as you type it. No substitution is performed.

You're right, this patch doesn't work. I must have mixed things up when I was trying different quoting methods and ended up submitting the wrong patch. I'm not very familiar with PowerShell; the key point here is figuring out how to properly quote arbitrary strings in PowerShell command arguments. It's much less obvious to me than in POSIX shells. 😢

@z-Fng
Copy link
Member

z-Fng commented Nov 15, 2025

This PR should be closed, as it isn't working as expected. See: #6373 (comment) & #6372 (comment)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants