vitor 860 Posted December 16, 2020 Share Posted December 16, 2020 Steps to reproduce:Make a Terminal Command Action.Type a command, but intend the first line one or more spaces.Save.Open the Terminal Command Action.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 post Share on other sites
deanishe 1,368 Posted December 16, 2020 Share Posted December 16, 2020 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 post Share on other sites
Andrew 803 Posted December 16, 2020 Share Posted December 16, 2020 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... Vero, Mr Pennyworth and deanishe 3 Link to post Share on other sites
Tsunami 13 Posted December 16, 2020 Share Posted December 16, 2020 https://en.wikipedia.org/wiki/Byte_order_mark 😉 Link to post Share on other sites
deanishe 1,368 Posted December 16, 2020 Share Posted December 16, 2020 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 post Share on other sites
Andrew 803 Posted December 16, 2020 Share Posted December 16, 2020 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 post Share on other sites
deanishe 1,368 Posted December 16, 2020 Share Posted December 16, 2020 3 hours ago, Andrew said: is this quite widespread? No. I've only seen it a few times. It's just a real headscratcher when some invisible character is breaking a script. I don't think it's necessary for Alfred to worry about. Andrew 1 Link to post Share on other sites
Andrew 803 Posted Friday at 01:09 PM Share Posted Friday at 01:09 PM This is now in 4.3.1 vitor 1 Link to post Share on other sites
Recommended Posts