-
Notifications
You must be signed in to change notification settings - Fork 743
Open
Description
I proposed this idea a while ago, but I can't remember where. I'm looking for comments/feedback.
The basic idea is to replace this:
shell.grep('foo', 'file.txt').to('other.txt');with
shell.grep('foo', 'file.txt', { '>': 'other.txt' });What does this fix?
It's currently not possible to mute echo() with redirection, which is kind of awkward. With this syntax, we can add support in src/common.js to temporarily add shell.config.silent = true. Then we just need to write echo() to respect that value. Voila.
New features?
This opens the door to some cool new features. Some ideas:
shell.rm('missing-file.txt', { '2>': 'error.log' }); // redirect stderr
shell.cat('first.txt', { '>>': 'second.txt' });
shell.cp('-r', 'src', 'out', { '2>&1': /* not sure what should go here :( */ });
shell.tail('file.txt', { '>': 'stdout.txt', '2>': 'stderr.txt' });A downside to this design is that we cannot support multiple redirects (e.g. echo foo > file1.txt > file2.txt).
Alternate ideas for syntax
shell.rm('missing-file.txt', { 2: 'error.log' }); // '2' instead of '2>'Reactions are currently unavailable