1

Is there a way to convert Linux style shell substitutions to Windows substitutions in Python?

Let's say there's a command in a Linux environment:

my_command=cd
${my_command} .. OR $my_command .. resolves to cd ..

In Windows:

SET my_command=cd
%my_command% .. resolves to cd ..

I want it so that if my environment is Windows, then I could take in a command and replace it with the Windows style substitution:

Sample input/output:

input: python myscript.py "${my_command}
output: "%my_command%"

Thanks!

Andrew
  • 1,355
  • 2
  • 13
  • 28

1 Answers1

-2
for x in sys.argv:
    if x.startswith("$"):
       print "%%%s%%"%(x[1:])
Joran Beasley
  • 110,522
  • 12
  • 160
  • 179