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

Doesn't work correct when .scpt-file does not end with an empty line #1

Closed
doekman opened this issue Apr 9, 2018 · 2 comments
Closed
Labels

Comments

@doekman
Copy link
Owner

doekman commented Apr 9, 2018

For some reason,osacompile adds an newline to the .scpt-file. It is a binary file, and I haven't found out how to remove this line.

Because a combined clean/smudge-filter operation should result in the exact same file, osagitfilter.sh removes the last line on a clean-operation if it is empty. This "hack" works in most cases. However, it fails when the original .scpt-file doesn't end with an empty line.

The test-case with file as2.scpt is already added (but it's commented out).

When you have a repository with an .scpt-file that does not end with an empty line, and when this repository is cloned, the clone will instantly contain "changes". The original repository will be "clean".

→ Workaround for now: always end your .scpt-file with an empty line.

@doekman doekman added the bug label Apr 9, 2018
@doekman
Copy link
Owner Author

doekman commented May 30, 2018

The command sed '${/^$/d;}' only removes last newline when last line is empty, so used perl -pe 'chomp if eof' instead (via stackoverflow).

However, now the smudge command fails in this use-case because the while IFS= read -r line; do loop "forgets" the characters between the last newline and the EOF, see this stackoverflow question.

doekman added a commit that referenced this issue May 30, 2018
@doekman
Copy link
Owner Author

doekman commented May 30, 2018

Print line after the while-loop with printf when it's not empty solves everything 😊

@doekman doekman closed this as completed May 30, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant