fix: make every commandName() branch runnable when pasted - #64
Draft
lionello wants to merge 1 commit into
Draft
Conversation
commandName() feeds the OAuth callback page the command a user pastes into a shell verbatim, so each branch has to run on its own. The bare basename fallback did not: for a checkout invoked from an unrelated cwd, or any install whose directory is not on the PATH, "onedrive" is simply not a command. Keep the relative path only while it stays short and below the cwd, fall back to the bare name when the script's directory really is on the PATH (what the user typed, and what reads best for a global install), and use an absolute path everywhere else. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
lionello
marked this pull request as draft
August 16, 2026 22:59
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.
commandName()feeds the OAuth callback page the command a user pastes into a shell verbatim, so every branch has to be runnable on its own. The bare-basename fallback was not: for a checkout invoked from an unrelated cwd, or any install whose directory is not on thePATH,onedriveis just not a command.Now: keep the relative path while it stays short and below the cwd, fall back to the bare name when the script's directory really is on the
PATH, and use an absolute path everywhere else.Before / after
Same function driven over a set of cwd + argv[1] + PATH combinations:
bin/onedrivebin/onedrivebin/onedrive/, deep relativeonedrive❌/Users/…/bin/onedriveonedriveonedriveonedrive❌/Users/…/bin/onedrive./onedrive./onedriveThe ❌ rows are the bug: a bare name for something that is not on the
PATH.Checks
process.argv[1]keeps thePATHsymlink rather than resolving through to the realpath, verified with an npm-global-install-shaped symlink (bin/od -> ../lib/od.jsrun viaPATH). So the newPATH-membership branch does fire for global installs — it is not silently dead.Path.isAbsolute(rel)guard is not a regression on Windows:path.win32.relative('C:\\Users\\me', 'D:\\tools\\onedrive')returnsD:\tools\onedrive, which is still an absolute, runnable path whichever branch returns it.Known rough edges (not addressed here)
PATHmatch is an exact string compare againstPath.dirname(argv[1]), so a non-canonical entry (/usr/local/bin/with a trailing slash, an unexpanded~, or a case difference on Windows) misses and falls through to the long absolute path. Runnable, just uglier than needed — normalizing both sides would fix it.my tools/onedrive→ shell readsmy). Pre-existing, but the absolute-path branch makes it more reachable, and it contradicts the verbatim-runnable premise. Wants shell quoting.🤖 Generated with Claude Code