Automator Shell Script Action Does Not Support Unicode Paths

Originator:andre.bergmedia
Number:rdar://8505850 Date Originated:02-Oct-2010 07:28 AM
Status:Behaves correctly (Closed) Resolved:Yes
Product:Mac OS X Automator Product Version:2.1 (247)
Classification:Serious Bug Reproducible:Always
 
Summary:

When using the Run Shell Script phase in Automator often times one wants to work exclusively on some paths, e.g. the selected Finder items maybe, and do something with those paths. Think renaming them (sidenote: the Rename Finder Items action is pretty much useless anyway). The problem arises when the paths contain characters with ordinal > 128. I'll just let an example speak for itself:

Given the path (containing an accented e):

/some/path/with/accéntedchar

the script will see this path as

/some/path/with/acce\U0301ntedchar

There is no working around this issue unfortunately. My guess would be composed character pairs are wrongfully split. 

Steps to Reproduce:

Use Automator.

Expected Results:

The shell script should see the path as 

/some/path/with/accéntedchar

Actual Results:

The shell script should see the path as
/some/path/with/acce\U0301ntedchar

Regression:

Unknown

Notes:

C'mon people. It is 2010 no less. Still so many issues with non ASCII data.
Automator could be so much more valuable if we had the power to use those shell scripts properly. 

04-Oct-2010 06:45 AM Andre Berg:
I was partially wrong about there being no alternative workaround for this issue. 
In Python at least using the unicodedata module one can convert to other Unicode normalization forms before using these path names in a script. I suspect there exists similar functionality for Perl but for Ruby, since SL uses 1.8 by default, there is no workaround. And I digging further I found out that the HFS filesystem works with decomposed unichar data as prefered format. So the Automator action is not entirely to blame for this. However, the discussion still remains if this should be handled before passing the filenames as text to the inputs of the shell scripts.

06-Oct-2010 02:57 AM Andre Berg:
In my testing stage I was passing some paths via Get Specified Text each on their own line. Further along in my original script I was using things like Python's os.path module which for some methods does checks on whether the path exists and refuses to do some processing if it doesn't. In other words, paths are not always treated like pure text. In my Get Specified Text action I had some paths with accented characters in them and even though I copy and pasted the paths directly from the Finder, the os.path module would claim these paths don't exist. By printing the the path strings using Python's unicode_escape codec I saw the path texts were storing the accented characters in decomposed form. 

However, just this morning I found one script where all worked well like it was supposed to. Eventually I tracked it down to the working script removing a trailing newline from each path line. 

I should have printed the repr form in my Python script then I would have seen that the text delivered by Get Specified Text was split into multiple lines which where fed to Run Shell Script set to use /usr/bin/python and stdin but keeping the newline character as last character for each line. I guess this would make this bug (that really was none - just my own misinformedness) resolved. 

In closing a suggestion: I have never developed actions myself so I don't know what facilities already exist, but it would be nice if this behaviour could be mentioned in the Run Shell Script description text (or help if there is such a thing). I guess there are a lot of people that come from AppleScript using Automator and this behaviour is a bit unexpected.

Thanks for getting back to me. If no reply I will mark this bug resolved.

06-Oct-2010 06:48 PM Andre Berg:
This issue has been verified as resolved and can be closed.

Comments


Please note: Reports posted here will not necessarily be seen by Apple. All problems should be submitted at bugreport.apple.com before they are posted here. Please only post information for Radars that you have filed yourself, and please do not include Apple confidential information in your posts. Thank you!