vdesabou Posted March 26, 2013 Share Posted March 26, 2013 Hi, I have a difference of behavior when I execute a ksh script in a "Run script" action in Alfred and in a terminal. The code is as following: SPEC_CHAR="ÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖØÙÚÛÜÝÞßàáâãäåæçèéêëìíîïðñòóôõöøùúûüýþÿ" NORM_CHAR="AAAAAAACEEEEIIIIDNOOOOOOUUUUYPSaaaaaaaceeeeiiiionoooooouuuuyby" mystring="têté" mystring=$(print $mystring | sed 'y/'${SPEC_CHAR}'/'${NORM_CHAR}'/') echo "$mystring" When I execute in terminal, I have: /Users/vincent/Downloads> ksh repro.ksh tete But when I execute it in Alfred (see workflow with reproduction here http://d.pr/f/ShJl ), I get an empty string for $mystring Any idea what's wrong here? Mac OS 10.8.3 Alfred: 2.0.2 Reproducible: Yes Link to comment
Andrew Posted March 26, 2013 Share Posted March 26, 2013 I think this may be either an issue with not importing environments or your workflow itself, I am moving into workflow questions so it can get some more eyes on the issue to maybe shed some light. Link to comment
jdfwarrior Posted March 26, 2013 Share Posted March 26, 2013 Hi, I have a difference of behavior when I execute a ksh script in a "Run script" action in Alfred and in a terminal. The code is as following: SPEC_CHAR="ÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖØÙÚÛÜÝÞßàáâãäåæçèéêëìíîïðñòóôõöøùúûüýþÿ" NORM_CHAR="AAAAAAACEEEEIIIIDNOOOOOOUUUUYPSaaaaaaaceeeeiiiionoooooouuuuyby" mystring="têté" mystring=$(print $mystring | sed 'y/'${SPEC_CHAR}'/'${NORM_CHAR}'/') echo "$mystring" When I execute in terminal, I have: /Users/vincent/Downloads> ksh repro.ksh tete But when I execute it in Alfred (see workflow with reproduction here http://d.pr/f/ShJl ), I get an empty string for $mystring Any idea what's wrong here? Mac OS 10.8.3 Alfred: 2.0.2 Reproducible: Yes Still not sure of the exact fix, but so far it appears that the issue lies in sed. If I manipulate it to search a single char and replace, it works perfectly. If I change it back to do the full replace that you are attempting, it fails. I'll continue to tinker with it and see what I can find. Link to comment
vdesabou Posted March 26, 2013 Author Share Posted March 26, 2013 Yes, it seems related to sed indeed, but that's strange that it is only happening when using Alfred. I've simplified the code: Looks like using combination of y/"accented character" is causing the issue: mystring="Têté" mystring=$(echo "$mystring" | sed y/ê/e/) echo "$mystring" is not working If i do: mystring="Têté" mystring=$(echo "$mystring" | sed y/t/b/) echo "$mystring" or : mystring="Têté" mystring=$(echo "$mystring" | sed s/ê/e/) echo "$mystring" It is working Weird... Thanks for your help, I'm getting crazy :-) Link to comment
vdesabou Posted March 26, 2013 Author Share Posted March 26, 2013 Hi David, I believe this is because LANG was not set when invoking the script with Alfred. In terminal, If I do: $ echo $LANG fr_FR.UTF-8 $ ksh repro.ksh tete $ unset LANG $ ksh repro.ksh sed: 1: "y/ÀÁÂÃÄÅÆÇÈÉ� ...": transform strings are not the same length So I added in the "repro2" repro.ksh script, export LANG='fr_FR.UTF-8' and now it works! Problem solved. Thanks Link to comment
jdfwarrior Posted March 26, 2013 Share Posted March 26, 2013 Hi David, I believe this is because LANG was not set when invoking the script with Alfred. In terminal, If I do: $ echo $LANG fr_FR.UTF-8 $ ksh repro.ksh tete $ unset LANG $ ksh repro.ksh sed: 1: "y/ÀÁÂÃÄÅÆÇÈÉ� ...": transform strings are not the same length So I added in the "repro2" repro.ksh script, export LANG='fr_FR.UTF-8' and now it works! Problem solved. Thanks Awesome! Nice work. Link to comment
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now