Shortcuts with number as parameter are broken

I have a shortcut where I want to provide a number as input (text and converting it to a number). Providing a negative number works, positive numbers won't work.

Using a Shell Script shortcuts run "Name" <<< 6 is working however.

You can find a sample shortcut here

This is a sample Makro invoking the Shortcut.
Execute Shortcut.kmmacros (4.0 KB)

I'd expect:

  • -6
  • -6
  • 6
  • 6

I get:

  • -6
  • -6
  • No
  • 6

Very curious.

It appears to be a bug with the shortcuts tool. Try this:

echo -n 6 | shortcuts run "Number Error"

Basically, it is not about numbers, I've had it happen with “x” or “xxx”, but curiously, now it has stopped happening.

Bizarre.

But unfortunately, a bug with shortcuts, not Keyboard Maestro. Reported as FB12441990.

You can add a line ending on the input text, and that will probably resolve it, and probably not affect anything. Maybe.

Thank you for your reply!
That's right. This isn't working either.

Is there a reason you don't use

tell application "Shortcuts Events" to run the shortcut named "Number Error" with input 6

or

shortcuts run "Number Error" <<< 6

no particular reason

That is essentially what I do, except that that includes the line ending, which is not really correct. It gets around the bug in shortcuts, but it includes an extraneous extra character which should not be included. Essentially it is the difference between:

echo -n 6 | …

and

echo 6 | …

The later (and the <<< method) includes a bonus line ending which is not what should be sent. In this case, it fixes the shortcuts bug, but in other cases it could be bad.

Ah, thank you. Makes sense now :slight_smile:

1 Like