Comments (4)
@felipensp good-first-issue To invite newcomers to start working on vlib?
from v.
Hi, I found there was logic on handling such characters, but they were commented out in a previous commit:
1bfcdaa#diff-61ea029cc6cc2d797366920e750069365bfbdddee28865dd540928cbd6048c95R76
What is the reason behind this?
from v.
Spawn ["sh", "-c", arg]
with arg
untouched.
I think we should strive to allow exactly the same thing as the native "sh -c" will allow. A little experimentation reveals that we should not strip away the line feeds rather keep them. Control flow characters are perfectly valid to send to sh -c arg
as arg
. A linefeed will be interpreted as a sequence of statements. One can probably send a shell script as-is as the arg
just by keeping the control characters as-is.
sh-5.2# sh -c "$(echo -e "ps 1\n\n")"
PID TTY STAT TIME COMMAND
1 ? S 0:00 /sbin/init
sh-5.2# sh -c "ps 1"
PID TTY STAT TIME COMMAND
1 ? S 0:00 /sbin/init
sh-5.2# sh -c "$(echo -e "ps\n1\n")"
PID TTY TIME CMD
25947 pts/4 00:00:01 fish
26060 pts/4 00:00:00 sh
26105 pts/4 00:00:00 sh
26106 pts/4 00:00:00 ps
sh: line 2: 1: command not found
sh-5.2# sh -c "$(echo -e "echo 1\necho 2")"
1
2
sh-5.2# sh -c "$(echo -e "true\nfalse")"
sh-5.2# echo $?
1
sh-5.2# sh -c "$(echo -e "false\ntrue")"
sh-5.2# echo $?
0
sh-5.2#
Notice that sh responded sh: line 2: 1: command not found
there. arg
is actually a script. everything allowed in a script should be allowed in arg
.
from v.
The tl;dr from the above analysis is that we should feed the linefeeds etc as-is. No filtering should be done.
The issue I ran into is due is the redirection stuff we add on the top. I think we can remove that. popen does nothing of that sort and I think we do not want to add a bunch of logic on top of what the C popen/pclose does.
EDIT: I was too late to the party to have an opinion on that, as we already had tests that checked for the stderr redirection. ;-) Anyways, I reworked how redirection is done to be a separate statement up front. This is likely very fragile and will only work for simple "one liners". If raw Posix shell execution is required, use popen.
from v.
Related Issues (20)
- v -translated compile fail with export
- VWeb; No function to send raw data HOT 1
- v fmt command error! HOT 2
- Possible struct def overwritten in generated C code.
- os.join_path() returns a non-rooted path when second argument is rooted path HOT 1
- Decimal data type
- Implicit Function Declaration Issue HOT 2
- "Hello world" does not work in browser with the "js_browser" backend
- Unclear how to compile a static binary HOT 3
- Compiler error when building global arrays of empty Structs HOT 1
- Compilation failure for global array when array size is a const in another module
- Signal 11 segmentation fault on Alpine but not macOS
- Allow path without filename for `-o`/`-output` flag
- after v fmt cause compile error
- io.stream_reader read function does not work HOT 5
- $dbg does not work everywhere
- "assignment mismatch: 1 variable(s) 0 value(s)" error for a simple generic if expression HOT 1
- cgen error for enum field with expression involving a constant HOT 3
- Silent Conversion of u64 to f64
- Alias of a fixed array can't be initialized HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from v.