Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

z -x sed error on OS X #125

Closed
keith opened this issue Jan 22, 2014 · 9 comments
Closed

z -x sed error on OS X #125

keith opened this issue Jan 22, 2014 · 9 comments

Comments

@keith
Copy link

keith commented Jan 22, 2014

When I run z -x from any directory on OS X I get this error from sed:

sed: 1: "/Users/ksmiley/.z": invalid command code k

This can be fixed by changing the sed command to:

sed -i '' "\:^${PWD}|.*:d" "$datafile";;

Where '' is the file extension used for the backup file (in this case nothing meaning no backup file is created)

@rupa
Copy link
Owner

rupa commented Jan 23, 2014

I get a different error '-i cannot be used with stdin' ... weird. Your error seems to be coming from your username.

In any event the fix for OSX doesn't work cross platform (Ubuntu at least) so I need to think about another solution.

@keith
Copy link
Author

keith commented Jan 23, 2014

Would it hurt to make a backup file like z.bak and just leave it there?

@rupa
Copy link
Owner

rupa commented Jan 23, 2014

Same issue, OSX wants -i EXT and ubuntu wants -iEXT

@keith
Copy link
Author

keith commented Jan 23, 2014

Ah crap.

@keith
Copy link
Author

keith commented Jan 23, 2014

Also not sure this is caused by my user name. Since if I try to run z -x in / I get the same issue. In which case at least $PWD evaluates to / although not the datafile path

@keith
Copy link
Author

keith commented Jan 23, 2014

Also changing it to sed -i -e ... works for me based on http://stackoverflow.com/questions/19456518/invalid-command-code-despite-escaping-periods-using-sed

@keith
Copy link
Author

keith commented Jan 24, 2014

Another option might to something like from this example: http://stackoverflow.com/a/13188531/902968

@keith
Copy link
Author

keith commented Feb 5, 2014

I can verify that this command:

sed -i -e "\:^${PWD}|.*:d" "$datafile";;

Works on both OS X and Ubuntu

@rupa rupa closed this as completed in 5741d90 Feb 5, 2014
@keith
Copy link
Author

keith commented Feb 5, 2014

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants