Project

Profile

Help

Cross platform Powershell and xslt3 command line arguments/options

Added by Martin Honnen over 2 years ago

I have stumbled into some oddity using SaxonJS's xslt3 command line tool with the cross platform Powershell (aka Powershell Core): it seems I have to wrap any SaxonJS/xslt3 option in single or double quotes to get xslt3 to parse it correctly, if not doing it I get error messages like e.g. xslt3 -xp:1 gving error Invalid command line input: 1.

SaxonCS or SaxonJ do process e.g. -qs:1 in that shell just fine and the normal cmd Windows processor does work with e.g. xslt3 -xp:1.

I am not sure why xslt3 gives those errors and I understand it might be more of a compatibility issue with Powershell than a problem of SaxonJS/xslt3, but I hope raising it here gives some insight as to what goes wrong and whether there is an easier fix than quoting each and every option when using xslt3 in that shell.


Replies (3)

Please register to reply

RE: Cross platform Powershell and xslt3 command line arguments/options - Added by John Lumley over 2 years ago

When originally writing the first xslt3 command line processor I came across this quirk of Powershell requiring quoting (I was the only member of the team to do all development work on a Windows machine) and didn't find any easy workaround. As most of my work needed only simple command line complexity I tended to stick with the usual CMD window.

RE: Cross platform Powershell and xslt3 command line arguments/options - Added by Michael Kay over 2 years ago

I've never used Powershell in serious anger. The rules seem pretty complex, see for example

https://www.red-gate.com/simple-talk/sysadmin/powershell/when-to-quote-in-powershell/

I'm wondering if the use of a digit in the command name "xslt3" might be making the difference?

RE: Cross platform Powershell and xslt3 command line arguments/options - Added by Martin Honnen over 2 years ago

Thanks for your feedback.

As to Mike's thought, whether "the use of a digit in the command name "xslt3" might be making the difference", I have created (a dotnet) command line tool named "cmdlinetest3" and run it in the Windows cmd shell, the Windows Powershell and the cross platform powershell with e.g. cmdlinetest3 -qs:1 -s:foo.xml -t and in all three shells it that way receives three command line arguments

-qs:1
-s:foo.xml
-t

so that digit doesn't in the command name doesn't seem to be the reason that xslt3 in Powershell somehow passes on command line arguments different to the "cmd" shell.

I will need to see whether I can write a NPM tool taking command line arguments and check whether that works differently and perhaps, if so, why, in "cmd" versus Powershell.

    (1-3/3)

    Please register to reply