Jump to content

Problem with formatting strings in Bash script


Recommended Posts

Not sure if I should file this under "bug report", so let me try here first, maybe I'm misunderstanding something...

 

I created a very simple workflow with one "Script Filter" as an input:

01.thumb.png.68e7905228fa05b2e081b30f23a44423.png

 

(pasting script as a text for easier reproducing if needed)

query=$1

val=5678

cat << EOB
{"items": [{"title": "Result: $(printf "%'.2f" $(( query * val )))"}]}
EOB

 

 

However, the workflow results don't appear formatted as I would expect it, specifically, it's missing the thousands separator.

 

This is how result looks like in Alfred popup:

02.thumb.png.67ae6011b781bc97bf13f0fb8655f791.png

 

This is how it looks in the debug window:

03.thumb.png.6a735fd2b09b01e6fb9a0de41e6afc69.png

 

And this is how the same script looks like if I run it in my Terminal (with "query" value hardcoded instead of using an argument):

04.png.eafbc1f2f8dd0b486d1e6d05696a530e.png

 

My question here is: why Alfred doesn't respect the formatting rules and in this case displays my result as "7006652.00" instead of "7,006,652.00"?

 

I'm using Alfred 4.6.4 (Build 1294) on macOS Monterey 12.3 (21E230).

 

Thanks for any info in advance!

Edited by errata
Added software versions
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...