Jump to content

Terminal Command strips beginning of textarea


vitor

Recommended Posts

Steps to reproduce:

  1. Make a Terminal Command Action.
  2. Type a command, but intend the first line one or more spaces.
  3. Save.
  4. Open the Terminal Command Action.
  5. Note the indent on the first line is gone.

If multiple empty lines were added at the top, those too will have been stripped.


This looks to be on purpose, but I’d argue it’s unexpected behaviour. Having leading spaces isn’t an issue to run a command, but not having them might be inconvenient.


Use case: prefixing a command with spaces is a common shell function to say “ignore this from history”. I have a few Terminal Command Actions which include functions and call them after, but I don’t want the functions to keep getting bumped in my history, so I prefix them with spaces. With the current behaviour, that doesn’t work.


Alfred 4.3 [1205]
macOS 10.14.6 (18G6042)

Link to comment
Share on other sites

3 hours ago, vitor said:

prefixing a command with spaces is a common shell function to say “ignore this from history”.

 

Did not know that. Thanks.

 

Generally agree that Alfred shouldn't strip leading/trailing whitespace. If it also strips BOMs, it should keep doing that, though.

Link to comment
Share on other sites

I am happy to change the Terminal Action to not trim.

 

4 hours ago, deanishe said:

If it also strips BOMs, it should keep doing that, though.

 

uhhh what is BOMs? *google search*

 

Quote

BOM - Bill of Materials: A list of the parts that are required to make up a final manufactured item. Generally generated as part of a MRP or similar system.

 

Ah yeah cool, I'll keep trimming these...

Link to comment
Share on other sites

5 hours ago, Andrew said:

uhhh what is BOMs? *google search*

 

Byte-order marks for UTF-16 and UTF-32 files. For some reason, people keep managing to insert them into Alfred scripts, then bash says "command not found: <BOM>/usr/bin/python" except the BOM is invisible, so it looks like "command not found: /usr/bin/python", which is terribly confusing.

Link to comment
Share on other sites

For this field, Alfred was trimming NSCharacterSet.whitespaceAndNewlineCharacterSet:

 

https://developer.apple.com/documentation/foundation/nscharacterset/1413732-whitespaceandnewlinecharacterset?language=objc

 

As far as I can tell, this doesn't include BOM.

 

@deanishe this is interesting, is this quite widespread? Do you think it would be worth warning in Alfred's Run Script / Script Filter objects if there is prefixed BOM?

 

 

Link to comment
Share on other sites

  • 1 month later...

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...