Skip to content

Scripts cannot be used for subcommands on Windows #632

@straight-shoota

Description

@straight-shoota

When invokied with a command that is not defined (say shards foo), shards tries to find a program called shards-foo and executes that. This is a simple mechanism to enable extensions of shards features outside of the main binary.

On Windows, the subcommand is required to be a binary exectuable. Scripts files (batch or PowerShell) are not supported.

Script files require a file extension in order to be considered executable in Windows shell. So the file would need to be called shards-foo.bat, but that doesn't match shards-foo.

If you explicitly use the extension as part of the subcommand name, execution still fails because shell scripts cannot be launced like executables on Windows outside a shell environment.

$ shards foobar.ps1
Unhandled exception: Error executing process: 'C:\crystal\crystal\shards-foobar.ps1': Exec format error (IO::Error)

On posix systems this all works because script files don't need an extension and can be executed directly without a shell.
This should work on Windows as well.

We'll need to figure out the details, but I suppose we could look for files with script extensions as well, and if found, execute them in a shell.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    Status

    Todo

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions