Comments (15)
I prefer one argument per line. Let me check how hard would it be to turn that into a single string for CreateProcess()
.
from fsatrace.
For maximum flexibility (basically so I can control the string to CreateProcess
) it would be nice if you just replaced each line with a space, then people can tailor the command line exactly. If you do any quoting etc around the arguments then I no longer have full flexibility.
from fsatrace.
For info, I managed to sort out the Shell stuff in Shake without requiring this, although it feels more fragile than would be ideal.
from fsatrace.
Hmm, I would say if any of the lines isn't properly passed as is to the invoked program we can consider that as a bug in fsatrace.
Having said that, what would you expect from a sequence like this?
fsatrace - -- ls *
and from an invocation with an args file containing the following?
ls
*
The second case seems more clear, no shell expansion should happen on any platform since those are the arguments we want to pass verbatim.
The former I'm not sure. I would prefer uniform behaviour across platforms and that probably means disabling glob expansion in fsatrace arguments (just a matter of linking with a different CRT object).
That means invoking the above from the command line on Windows will yield a different result from just invoking ls *
in the cmd prompt, but I'm ok with that since the tool is supposed to be invoked from a build system with the right argv[]
from fsatrace.
This branch has an implementation of this feature:
https://github.com/jacereda/fsatrace/tree/file-args
from fsatrace.
Agreed, I think having fsatrace do no shell expansion is the right approach - anyone who wants that can prepend cmd /c
.
from fsatrace.
Merging this branch gives me:
make: *** No rule to make target `win/emit.h', needed by `win/fsatracedll32.o'. Stop.
A make clean
fixed it - not sure if that's a missing dependency somewhere?
What I'm really trying to do is create the CreateProcess command line of
cmd /c whatever the user typed unmodified
If I do:
cmd
/c
output\command\shake_helper.exe "otest x"
Then you generate:
cmd /c "output\command\shake_helper.exe \"otest x\""
Which is wrong - escaping "
with \"
is incorrect on Windows - it should be double or triple quote, but in insanely complicated ways which are virtually impossible to get right (and aren't even total - there are certain quotes you can't properly escape).
My favourite would be to just do unlines
for Windows, and not try and reescape them, because there is no robust way of doing it - just expect the person producing the input to properly craft it. I'd be fine if this was behind a --direct
flag or similar. Alternatively, maybe @@file
to be the "I know what I'm doing" command, which maybe fits better with your existing syntax.
(With this, I think I'll have nailed the Shake/Shell issues entirely, and fsatrace will be able to do everything properly.)
from fsatrace.
Oh, the argv output also seems a little messed up:
C:\Neil\shake>fsatrace bob.txt -- @cmds.txt
cmd /c "output\command\shake_helper.exe \"otest x\""
shake_helper.exe: shake_helper.hs:(11,9)-(19,41): Non-exhaustive patterns in case
fsatrace.exe(7504): error: command failed with code 1:
argv[0]=
argv[0]=
argv[0]=
argv[0]=
argv[0]=
argv[0]=
ar
argv[1]=v[0]=
argv[0]=
...
from fsatrace.
The args should be dumped properly in https://github.com/jacereda/fsatrace/tree/file-args
from fsatrace.
Confirmed, the args are now dumped properly. I still would like a way to do the carefully crafted command line though.
from fsatrace.
As an example of where the precise command line is required, start cmd
and start "cmd"
do different things - the first quoted argument to start
is treated as the title, whereas if the first is not quoted its treated as a command.
from fsatrace.
I think I'll try the @@args
syntax. In any case I'm tempted to say your example should be handled properly if the args are:
start
cmd
...
or:
start
"cmd"
...
And if they are not I want to fix that in the @args
syntax too. IIRC args that are already quoted are passed verbatim.
from fsatrace.
Quite possibly, if you consider something which is only alpha characters to be already quoted. My concern is if I want to pass foo " bar
or similar to a command line I'll have to reverse your "when to escape" logic and perhaps there won't be an input that can produce the output I am after. For Shake, I also don't want to have to munge the users input at all, which is why @@
is preferable.
from fsatrace.
Given we can just create a .bat file and run that, I think I'll also remove the @foo
handling, is that OK?
from fsatrace.
From Shake usage, yes. Although having an @ variant of other commands sometimes comes in handy, so it might be a future feature request from someone. That said, if it becomes more of a library, then an @ version doesn't make as much sense.
from fsatrace.
Related Issues (20)
- sh.exe test fails on Windows
- Doesn't trace execution on Windows HOT 4
- Make a release HOT 1
- Output file even on non-zero exit code HOT 1
- Tracing multiple subprocesses doesn't work on Windows HOT 8
- Can't trace Go code on Linux HOT 2
- Can't trace gcc on Mac HOT 2
- fsatrace isn't recording executable being run as a "read". HOT 6
- Clarify (or clean up) the Windows makefile HOT 1
- Can't spawn a 32bit process from a .bat file HOT 3
- Tracking reads from non-existing files HOT 6
- Corruption of PATH HOT 2
- failures on ubuntu 20.04 HOT 6
- Quantifying fsatrace's coverage HOT 2
- Consider ETW on Windows HOT 3
- Removing a symlink looks like removing its target HOT 8
- segfault in emiting op HOT 8
- Tracing mkdir syscalls
- Basic tracing does not appear to work on macOS Monterey Version 12.5.1 HOT 3
- Fails to compile on GitHub Mac runners (incompatible architecture) HOT 8
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 fsatrace.