Skip to content

New switch -spo[d|c|r] inconsistent description and/or behaviour on Windows. #209

@bulbaka

Description

@bulbaka

Environment:
Microsoft Windows 10 Pro 22H2 build 19045 revision 6466
7-Zip 26.01 x64

A new switch that is now (since 26.01) to define the output directory generation mode in the description is put as follows: -spo[d|c|r]
So, I am assuming that [d|c|r] symbols within the square brackets are optional.
It implies, -spo alone would be allowed with the results identical to -spor (default).
In fact, -spo fails altogether, 7-Zip throws an error ERROR: Too short switch: -spo.

The -spod has the asterisk * character explicitly mentioned in its description, but fails to work with it, with 7-Zip throwing an error that it cannot create the output directory.

The -spoc does not have the asterisk * character explicitly mentioned in its description, so I just tried it as it is, and it fails, with 7-Zip throwing an error that it cannot create the output directory (same as -spod).

The -spo behavior looks like an inconsistency.
The -spod and -spoc handling of the asterisk * in the output path looks like a bug.

I used the following PowerShell .ps1 script for my tests (please, find some additional details in the script's comments).

Out of 10 tests in total, 7-Zip succeeds six times and fails four times (twice with -spo with/without asterisk * in the output path, once with -spod with asterisk * in the output path, and once with -spoc with asterisk * in the output path):

$env:path += ";$env:ProgramFiles\7zip"

$zip = Get-ChildItem -path $pwd -file -recurse -force -filter *.zip|sort LastWriteTime|select -last 1
$zip.FullName

# -o"$output"    Output directory where to extract files
# -o"$output\*"  Extract archives to the output directory subfolders with names of the archives
# assuming the results now would be identical to -spor (default)
$output = "$env:Temp\7z_test\default_asterix\*"
$output|Write-Host -f Yellow
7z.exe x -r -aoa -y $zip -o"$output"
# OK: results in unpacking into : $env:Temp\Temp\7z_test\default_asterix\ArchiveName\[archive_contents...]
$output = "$env:Temp\7z_test\default"
$output|Write-Host -f Yellow
7z.exe x -r -aoa -y $zip -o"$output"
# OK: results in unpacking into : $env:Temp\Temp\7z_test\default\[archive_contents...]

# -spo[d|c|r] Output directory generation mode since 26.01
# assuming that [d|c|r] within square brackets are optional
# so -spo alone would be allowed with the results identical to -spor (default)
$output = "$env:Temp\7z_test\spo_asterix\*"
$output|Write-Host -f Yellow
7z.exe x -r -aoa -y $zip -spo -o"$output"
# ERROR: Too short switch: -spo
$output = "$env:Temp\7z_test\spo"
$output|Write-Host -f Yellow
7z.exe x -r -aoa -y $zip -spo -o"$output"
# ERROR: Too short switch: -spo

# -spod : for Linux/Posix/macOS: -o{dir_path} specifies the direct path to the output directory.
#         The asterisk (*) character in {dir_path} will not be replaced by the archive name.
$output = "$env:Temp\7z_test\spod_asterix\*"
$output|Write-Host -f Yellow
7z.exe x -r -aoa -y $zip -spod -o"$output"
# ERROR: Cannot create output directory : ... : $env:Temp\Temp\7z_test\spod_asterix\*\
$output = "$env:Temp\7z_test\spod"
$output|Write-Host -f Yellow
7z.exe x -r -aoa -y $zip -spod -o"$output"
# OK: results in unpacking into : $env:Temp\Temp\7z_test\spod\[archive_contents...]

# -spoc : 7-Zip will concatenate the path specified in -o{dir_path} with the archive name to form the final path to the output directory.
#         The asterisk (*) character is not mentioned in the description so just testing the behavior
$output = "$env:Temp\7z_test\spoc_asterix\*"
$output|Write-Host -f Yellow
7z.exe x -r -aoa -y $zip -spoc -o"$output"
# ERROR: Cannot create output directory : ... : $env:Temp\Temp\7z_test\spoc_asterix\*\ArchiveName\
$output = "$env:Temp\7z_test\spoc"
$output|Write-Host -f Yellow
7z.exe x -r -aoa -y $zip -spoc -o"$output"
# OK: results in unpacking into : $env:Temp\Temp\7z_test\spoc\ArchiveName\[archive_contents...]

# -spor : 7-Zip will replace asterisk (*) character in the path specified in the -o{dir_path} with the archive name.
#         This is the default option.
$output = "$env:Temp\7z_test\spor_asterix\*"
$output|Write-Host -f Yellow
7z.exe x -r -aoa -y $zip -spor -o"$output"
# OK: results in unpacking into : $env:Temp\Temp\7z_test\spor_asterix\ArchiveName\[archive_contents...]
$output = "$env:Temp\7z_test\spor"
$output|Write-Host -f Yellow
7z.exe x -r -aoa -y $zip -spor -o"$output"
# OK: results in unpacking into : $env:Temp\Temp\7z_test\spor\[archive_contents...]

pause

Best regards.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions