CDSoft / panda

Panda is a Pandoc Lua filter that works on internal Pandoc's AST. Panda is heavily inspired by [abp](http:/cdelord.fr/abp) reimplemented as a Pandoc Lua filter.
https://cdelord.fr/panda
GNU General Public License v3.0
44 stars 5 forks source link

Shell commands don't work on Windows #5

Closed bandel65 closed 11 months ago

bandel65 commented 3 years ago

e.g. "Echo Hello World{cmd=cmd.exe}" or "Echo Hello World{cmd=cmd.exe /c}"

CDSoft commented 3 years ago

Do you have any error message?

This works on Linux:

`echo Hello World`{cmd=sh}

If cmd needs more arguments, the whole command should be a quoted string otherwise Pandoc split words and the arguments won't be included in cmd:

`echo Hello World`{cmd="cmd /c"}
bandel65 commented 3 years ago

Christophe, thanks for getting back to me so quickly. ☺ No error message. It just hangs. If I try cmd=”sh” I get a panda lua system call error because there is no “sh” command on Windows (unless I install Cygwin ;-).

From: CDSoft @.> Sent: Thursday, November 4, 2021 3:34 AM To: CDSoft/panda @.> Cc: Bill Andel @.>; Author @.> Subject: [External] Re: [CDSoft/panda] Shell commands don't work on Windows (Issue #5)

Do you have any error message?

This works on Linux:

echo Hello World{cmd=sh}

If cmd needs more arguments, the whole command should be a quoted string otherwise Pandoc split words and the arguments won't be included in cmd:

echo Hello World{cmd="cmd /c"}

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHubhttps://github.com/CDSoft/panda/issues/5#issuecomment-960632846, or unsubscribehttps://github.com/notifications/unsubscribe-auth/AWKXBGMJWHHQX7XZKXOONRLUKJOQPANCNFSM5HKAAAFA. Triage notifications on the go with GitHub Mobile for iOShttps://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Androidhttps://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub.

CDSoft commented 3 years ago

Did you try cmd="cmd /c" (with quotes around cmd /c)?

There may be another problem. cmd may expect specific file names (e.g. with the .bat extension). On Linux the filename does not matter. The script is saved to a temporary file which name may not be supported by cmd.

The doc says /e disables the extensions. And also /q to avoid unexpected outputs from cmd.

Maybe:

`echo Hello World`{cmd="cmd /e /q /c"}

or

`echo Hello World`{cmd="cmd /e:off /q /c"}
bandel65 commented 3 years ago

Had it in quotes, but hadn’t tried other options. I’ll look into that. Thanks.

From: CDSoft @.> Sent: Thursday, November 4, 2021 8:43 AM To: CDSoft/panda @.> Cc: Bill Andel @.>; Author @.> Subject: [External] Re: [CDSoft/panda] Shell commands don't work on Windows (Issue #5)

Did you try cmd="cmd /c" (with quotes around cmd /c)?

There may be another problem. cmd may expect specific file names (e.g. with the .bat extension). On Linux the filename does not matter. The script is saved to a temporary file which name may not be supported by cmd.

The doc says /e disables the extensions. And also /q to avoid unexpected outputs from cmd.

Maybe:

echo Hello World{cmd="cmd /e /q /c"}

or

echo Hello World{cmd="cmd /e:off /q /c"}

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHubhttps://github.com/CDSoft/panda/issues/5#issuecomment-961168880, or unsubscribehttps://github.com/notifications/unsubscribe-auth/AWKXBGPPIPHP6EOXJMT63KLUKKSZ5ANCNFSM5HKAAAFA. Triage notifications on the go with GitHub Mobile for iOShttps://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Androidhttps://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub.

bandel65 commented 3 years ago

None of that worked. Idiomatically, I don’t think Windows cmd.exe is capable of being invoked in this way, but I’m not certain.

From: CDSoft @.> Sent: Thursday, November 4, 2021 8:43 AM To: CDSoft/panda @.> Cc: Bill Andel @.>; Author @.> Subject: [External] Re: [CDSoft/panda] Shell commands don't work on Windows (Issue #5)

Did you try cmd="cmd /c" (with quotes around cmd /c)?

There may be another problem. cmd may expect specific file names (e.g. with the .bat extension). On Linux the filename does not matter. The script is saved to a temporary file which name may not be supported by cmd.

The doc says /e disables the extensions. And also /q to avoid unexpected outputs from cmd.

Maybe:

echo Hello World{cmd="cmd /e /q /c"}

or

echo Hello World{cmd="cmd /e:off /q /c"}

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHubhttps://github.com/CDSoft/panda/issues/5#issuecomment-961168880, or unsubscribehttps://github.com/notifications/unsubscribe-auth/AWKXBGPPIPHP6EOXJMT63KLUKKSZ5ANCNFSM5HKAAAFA. Triage notifications on the go with GitHub Mobile for iOShttps://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Androidhttps://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub.

CDSoft commented 3 years ago

I pushed a quick fix to add the file extension to the temporary script name according to the command. cmd.exe may accept to execute scripts with the .cmd extension. It seems to work on cmd.exe on Linux with Wine.