Repository navigation
fix: prefix paths starting with - with ./ in cp, md5sum and md5 - #92
Merged
Merged
Conversation
Quoting a path for the shell doesn't stop cp, md5sum or md5 from
parsing a name that starts with "-" as an option: cp_file("-r", "copy")
ran "cp -r copy" and failed with a usage error. GNU and BSD cp and
md5sum, and macOS md5, all accept "--" to end the options.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
shcheklein
added a commit
to kushaldave002/sshfs
that referenced
this pull request
Nov 28, 2026
Leave put_file and pipe_file as they are on main, and give bytes paths in _parent the parents fsspec gives str paths, so str behavior doesn't change. Uploads to relative and top-level paths are fixed in fsspec#91, and "--" before paths in shell commands is added in fsspec#92. The upload test uses absolute paths, since relative uploads depend on fsspec#91. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
shcheklein
commented
Nov 29, 2026
shcheklein
left a comment
Collaborator
Author
There was a problem hiding this comment.
(AI-generated review by Copilot)
Clean, minimal fix for option-like leading-dash paths (-r, etc.). Inline notes on the bare "-" edge case in md5sum/md5, centralizing shell command construction with #86, and splitting/renaming the test.
There was a problem hiding this comment.
🟢 Approval recommended
No active review issues were identified for the change addressing leading-dash filenames in remote copy and checksum operations.
No open issues 🎉
What changed in this PR
This PR fixes remote copy and checksum operations for relative paths beginning with -, preventing filenames from being interpreted as command options.
Changes:
- Adds
--before path arguments passed tocp,md5sum, andmd5. - Adds a regression test covering copy and checksum operations with leading-dash filenames.
| File | Description |
|---|---|
tests/test_sshfs.py |
Tests copying and checksumming a file named -r. |
sshfs/spec.py |
Separates command options from path arguments with --. |
Review effort: Balanced
md5sum and md5 read stdin for a "-" argument even after "--", so
checksum("-") hung, because the command's stdin is never closed. A "./"
prefix keeps both "-" and option-like names such as "-r" from being
parsed by cp, md5sum and md5.
The test is split into a cp_file test and a checksum test, each next
to its existing test. The checksum test covers "-" and has a timeout,
so a regression fails instead of hanging.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
cp_fileandchecksumquote paths for the shell, but quoting doesn't stopcp,md5sumormd5from parsing a name that starts with-:fs.cp_file("-r", "copy")runscp -r copy, which fails with a usage error.fs.checksum("-r")fails the same way with GNUmd5sum, and macOSmd5treats-ras an option.fs.checksum("-")makesmd5sumandmd5read stdin instead of the file. The command's stdin is never closed, so the call hangs.This prefixes paths that start with
-with./, which fixes both cases. Passing--wouldn't fix the second, becausemd5sum -- -andmd5 -- -still read stdin. Only relative paths can start with-, and./resolves them against the same directory.The checksum test has a timeout, so a regression fails instead of hanging the suite.
This touches the same lines as #75 and #86. Split out of #86.
🤖 Generated with Claude Code