Trying to create Perl actions... and finding some errors

I have been trying to test-drive this action

name: 'Hello Perl'
description: 'Greet someone with Perl'
inputs:
  who-to-greet:  # id of input
    description: 'Who to greet'
    required: true
    default: 'World'
runs:
  using: "composite"
  steps:
    - run: use v5.14; say "Hi ${{ inputs.who-to-greet}}‼"
      shell: perl

It failed with:

Error: Invalid shell option. Shell must be a valid built-in (bash, sh, cmd, powershell, pwsh) or a format string containing '{0}'

Ok, fair enough. I though it was output to a file with the shebang in front, and it wasn’t.

Could be a nice feature request, however

Anyway, I was intrigued by the last part, “format string containing {0}”, which opens the door to yet other kind of shell-formatted or non-shell actions. What does it mean?

OK, I got the answer from this documentation, which shows the commands that are used for every shell.

A little aside here: it would probably be very easy to set the same thing that Python has going for Perl, if the source is available, I’d be willing to do a PR. Second aside, the error message above does not mention Python; maybe the list of shells should be dynamic.

Basically, you need to simply add {0} at the end of a preexisting program you want your script to run. That is:

    - run: use v5.14; say "Hi ${{ inputs.who-to-greet}}‼"
      shell: perl {0}

This works as intended, as shown in this run

2 Likes