Sending ascii characters through system or dos command
Mostrar comentarios más antiguos
I'd like to send a system command to obtain the commit of a git tag, I'm trying to do this using the git rev-parse functionality:
cmd = 'git rev-parse v1.3^{}'
[resp,cmdOut] = system(cmd)
Gives me the response:
resp =
128
cmdOut =
'v1.3{}
fatal: ambiguous argument 'v1.3{}': unknown revision or path not in the working tree.
Use '--' to separate paths from revisions, like this:
'git <command> [<revision>...] -- [<file>...]'
'
The ^ character does not arrive in the shell. I tested this by:
cmd = 'echo git rev-parse v1.3^{}'
[resp,cmdOut] = system(cmd)
which gives me
resp =
0
cmdOut =
'git rev-parse v1.3{}
'
I'm on a windows computer. I tried the same yesterday in octave online (https://octave-online.net/) which does give me the expected respone. I do think that octave online runs linux though.
5 comentarios
Walter Roberson
el 9 de Sept. de 2020
try putting in \^ instead of ^
Jan Loof
el 9 de Sept. de 2020
Walter Roberson
el 9 de Sept. de 2020
Hmmm, maybe
cmd = 'echo git rev-parse v1.3^^{}'
(I am not using Windows so I cannot easily test myself.)
Rik
el 9 de Sept. de 2020
That works on my system (W8+R2020a), so feel free to move that to the answer section.
Jan Loof
el 9 de Sept. de 2020
Respuesta aceptada
Más respuestas (1)
Rik
el 9 de Sept. de 2020
0 votos
If you don't find a real solution: you can write the command to a bat file and run that instead. You can use the > symbol to redirect the output to a plain text file, which you can then read back.
You might want to use tempname to generate file names in the temp folder of the system running your function. That way you have the best chance of write access.
Categorías
Más información sobre Source Control en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!