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

Provide a mechanism for writing safe wrappers to external commands #371

Open
xiaq opened this issue Jun 28, 2017 · 1 comment
Open

Provide a mechanism for writing safe wrappers to external commands #371

xiaq opened this issue Jun 28, 2017 · 1 comment

Comments

@xiaq
Copy link
Member

@xiaq xiaq commented Jun 28, 2017

External commands mix options and arguments together, and this is a common source of errors. The following POSIX shell code breaks when there is any file whose name starts with a dash:

for f in *; do
  ls $f
done

The correct way is to always write ls -- $f, but that is cumbersome.

In Elvish options use the special &name=value syntax and are completely from arguments. It should be possible to wrap external commands. For instance, a "safe" version of ls can be used like this

ls &l # passes the "l" option; calls "e:ls -l"
ls -l # lists the "-l" file; calls "e:ls -- -l"
ls &l $x # calls "e:ls -l -- $x"
@ganeshi4u
Copy link

@ganeshi4u ganeshi4u commented Jun 30, 2017

@xiaq i said don't inspire from others -_-

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

Successfully merging a pull request may close this issue.

None yet
2 participants