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

🙏🏻 [feat/req] supply $0/%0 to shimmed scripts (cross-platform) #9874

Open
rivy opened this issue Mar 23, 2021 · 4 comments
Open

🙏🏻 [feat/req] supply $0/%0 to shimmed scripts (cross-platform) #9874

rivy opened this issue Mar 23, 2021 · 4 comments
Labels
feat new feature (which has been agreed to/accepted)

Comments

@rivy
Copy link
Contributor

rivy commented Mar 23, 2021

It's helpful to supply users with exact, functional command line constructions when giving feedback (via error message suggestions, --help or --usage) about correct execution of a utility. Unfortunately, the initiating command ($0 or %0 for windows) is lost in the current shimming process, so the called script doesn't known the command that actually initiated it. The shims can be hacked to provide this information via environment variables or a command line option, but it would be better to have a formalized supplier for that information.

@rivy
Copy link
Contributor Author

rivy commented Mar 23, 2021

As an example of an implementation used locally:

% generated by deno install (revised locally) %
@set "ERRORLEVEL="
@setLocal
@set _DENO_SHIM_0_=%0
@set _DENO_SHIM_*_=%*
@deno.exe "run" "--allow-read" "--allow-write" "--allow-net" "--allow-env" "--allow-run" "--allow-plugin" "--allow-hrtime" "file:///C:/Users/Roy/OneDrive/Projects/deno/dexter/repo.deno.dexter/src/cli/dexter.ts" %*
@goto _undefined_ 2>NUL || @for %%G in ("%COMSPEC%") do @title %%~nG & @"%COMSPEC%" /d/c "@exit %ERRORLEVEL%"

It works, but it requires revising the default shim and definitely feels like a bit of a "hack".

@rivy
Copy link
Contributor Author

rivy commented Mar 27, 2021

The complementary POSIX shim would only need one additional line:

_DENO_SHIM_0_=$0
deno "run" "--allow-read" "--allow-write" "--allow-net" "--allow-env" "--allow-run" "--allow-plugin" "--allow-hrtime" "file:///C:/Users/Roy/OneDrive/Projects/deno/dexter/repo.deno.dexter/src/cli/dexter.ts" "$@"

@rivy rivy changed the title feature: supply $0/%0 to shimmed scripts (cross-platform) 🙏🏻 [feat/req] supply $0/%0 to shimmed scripts (cross-platform) Apr 4, 2021
@stale
Copy link

stale bot commented Jun 3, 2021

This issue has been automatically marked as stale because it has not had recent activity. It will be closed in 7 days if no further activity occurs. Thank you for your contributions.

@stale stale bot added the stale label Jun 3, 2021
@rivy
Copy link
Contributor Author

rivy commented Jun 3, 2021

Not stale.

@stale stale bot removed the stale label Jun 3, 2021
@ry ry added the feat new feature (which has been agreed to/accepted) label Jun 3, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feat new feature (which has been agreed to/accepted)
Projects
None yet
Development

No branches or pull requests

2 participants