Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug] getopt.ps1 splits literal strings and full file paths into multiple strings #5688

Closed
BinToss opened this issue Oct 11, 2023 · 3 comments
Labels

Comments

@BinToss
Copy link

BinToss commented Oct 11, 2023

Linked Issues: #5313, #5326

Bug Report

Current Behavior

$opt, $other, $err = getopt $Args 'g' 'global'

$argv = @($argv -split ' ')

When a quoted string is present in $Args, it is treated as one string. get-opt.ps1 does not check for quoted strings and will split them if they contain spaces.

Expected Behavior

A path containing spaces should not be split if it is enclosed with single- or double-quotes.

test with...

scoop shim add edge 'C:\Program Files (x86)\Microsoft\Edge\Application\msedge.exe' '--' --global

Additional context/output

image

Possible Solution

Splitting arguments by spaces is redundant. The $Args variable is an array of strings which have already been split by whitespace. Doing so again is redundant and can lead to issues like this one.
I recommend requiring users to enclose an arguments in in quotes if it must contain whitespace.

System details

Windows version 11
OS architecture 64bit
PowerShell version 7.3.7

Scoop Configuration

{
  "last_update": "2023-10-11T02:06:48.3814390-07:00",
  "alias": {
    "upgrade": "scoop-upgrade"
  },
  "scoop_repo": "https://github.com/ScoopInstaller/Scoop",
  "scoop_branch": "master"
}
@BinToss BinToss added the bug label Oct 11, 2023
@hagaigold
Copy link
Contributor

look like #5313 / #5326

@BinToss
Copy link
Author

BinToss commented Oct 19, 2023

Ah, yes. It is a duplicate. I wonder why I those didn't turn up when I searched for existing issues...

Close this as Duplicate?

@hagaigold
Copy link
Contributor

hagaigold commented Oct 19, 2023

Ah, yes. It is a duplicate. I wonder why I those didn't turn up when I searched for existing issues...

you can switch to the develop branch, if you don't mind using the not released version:

scoop config scoop_branch develop

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants