Jump to content

Bash not working properly

Recommended Posts

I tried running this script in a workflow




string="a FeW WOrdS"

echo "$string"



But then in the Alfred workflow debugger, I get 



/Users/me/Library/Caches/com.runningwithcrayons.Alfred/Workflow Scripts/A4DF2A96-E3FC-4D43-BAEC-BD9CDFAA265E: line 10: ${string,,}: bad substitution


This script works in my normal terminal, so why doesn't it work in an Alfred script?



Edited by himat
Link to comment

It looks like it's being run with /bin/bash in Alfred, not /usr/local/bin/bash. /bin/bash is an older version and doesn't support that syntax.


Presumably you've pasted that script in a Script box with Language = /bin/bash. If you want to run a script with /usr/local/bin/bash, you need to save it as a separate file.

Link to comment

Making it a script fixed that problem, but it seems there's still some problem with used `sed` in alfred.


string="helLO tHEre"
echo "$string" | sed 's/.*/\L&/'

This works in the terminal and outputs "hello there".


But when I run (even as an external script) within Alfred, it outputs "LhelLO tHEre". 

Why doesn't this work?

Link to comment

Here's the workflow: https://www.dropbox.com/s/18e6nwg6om4yymh/snippets with scripts.alfredworkflow?dl=0


You should copy some text to your clipboard, then type ".title", and the text should be turned into title case, but it doesn't work within alfred for some reason.


  1. Alfred 4.0.7 [1131]
  2. macOS Mojave 10.14.5 
  3. System bash (via `bash --version` in terminal): GNU bash, version 5.0.2(1)-release (x86_64-apple-darwin17.7.0)

Thank you

Link to comment

It doesn't work because you've apparently reconfigured your shell to use a non-standard  sed. Presumably, you've installed gnu-sed via Homebrew and have that setup at /usr/local/bin/sed.

When you run sed in Alfred, you get the default version at /usr/bin/sed.

Alfred doesn't use your shell environment because it isn't launched from your shell, so /usr/local/bin isn't on PATH in Alfred. If you want to run /usr/local/bin/sed from Alfred, you have to call it as /usr/local/bin/sed, not just sed, or if you're running a whole bunch of stuff from /usr/local/bin, put export PATH=/usr/local/bin:$PATH at the top of your script.

Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Create New...