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

Mac OS X 10.11: mktemp and date calls fail since they don't use GNU coreutils #66

Open
anarchivist opened this issue Nov 16, 2017 · 2 comments

Comments

@anarchivist
Copy link

anarchivist commented Nov 16, 2017

Trying latest Quack from master. HTML file generation is leading to empty (zero-byte) files. Seeing lots of errors/messages like the following:

My local workaround was to use the coreutils versions installed by Homebrew by editing the scripts to use the executables with the g prefix (e.g. gmktemp and gdate).

curtido:quack matienzo$ ./quack.sh ~/Desktop/in ~/Desktop/out
Using presentation.sh located in /Users/matienzo/Documents/Code/quack
Quack starting at Thu Nov 16 12:42:09 PST 2017
Processing /Users/matienzo/Desktop/innodata_in 12:42:09
usage: date [-jnu] [-d dst] [-r seconds] [-t west] [-v[+|-]val[ymwdHMS]] ...
            [-f fmt date | [[[mm]dd]HH]MM[[cc]yy][.ss]] [+format]
usage: date [-jnu] [-d dst] [-r seconds] [-t west] [-v[+|-]val[ymwdHMS]] ...
            [-f fmt date | [[[mm]dd]HH]MM[[cc]yy][.ss]] [+format]
usage: date [-jnu] [-d dst] [-r seconds] [-t west] [-v[+|-]val[ymwdHMS]] ...
            [-f fmt date | [[[mm]dd]HH]MM[[cc]yy][.ss]] [+format]
usage: date [-jnu] [-d dst] [-r seconds] [-t west] [-v[+|-]val[ymwdHMS]] ...
            [-f fmt date | [[[mm]dd]HH]MM[[cc]yy][.ss]] [+format]
usage: date [-jnu] [-d dst] [-r seconds] [-t west] [-v[+|-]val[ymwdHMS]] ...
            [-f fmt date | [[[mm]dd]HH]MM[[cc]yy][.ss]] [+format]
usage: date [-jnu] [-d dst] [-r seconds] [-t west] [-v[+|-]val[ymwdHMS]] ...
            [-f fmt date | [[[mm]dd]HH]MM[[cc]yy][.ss]] [+format]
usage: date [-jnu] [-d dst] [-r seconds] [-t west] [-v[+|-]val[ymwdHMS]] ...
            [-f fmt date | [[[mm]dd]HH]MM[[cc]yy][.ss]] [+format]
usage: date [-jnu] [-d dst] [-r seconds] [-t west] [-v[+|-]val[ymwdHMS]] ...
            [-f fmt date | [[[mm]dd]HH]MM[[cc]yy][.ss]] [+format]
mktemp: illegal option -- -
usage: mktemp [-d] [-q] [-t prefix] [-u] template ...
       mktemp [-d] [-q] [-u] -t prefix
./quack.sh: line 385: $TMP: ambiguous redirect
./quack.sh: line 386: $TMP: ambiguous redirect
./quack.sh: line 387: $TMP: ambiguous redirect
./quack.sh: line 388: .: filename argument required
.: usage: . filename [arguments]
usage: rm [-f | -i] [-dPRrvW] file ...
       unlink file
Processing /Users/matienzo/Desktop/in/JT405KK9123 12:42:09
@tokee
Copy link
Owner

tokee commented Nov 17, 2017

Thank you for the report. Unfortunately I don't have access to a Mac, so it is hard for me to fix. juxta relies on coreutils, so it is a bit of a pain that OS X has mktemp and date with different syntax.

One work-around for mktemp is to create a helper-function. The cross-platform problem is that it needs to be able to create TMP-files with a given file extension and not just fully random names.

dateis a bit more tricky:

  • It is mostly used for measuring time with the format modifier +%s%N. According to Darwin data man the format-option also exists there, but according to Darvin strftime(3) man the %N (nanoseconds) does not.
  • It is also used to read the last modified time from a file with -r, which does something else under OS X. I should probably use statfor that.

@anarchivist
Copy link
Author

anarchivist commented Nov 17, 2017

Hi @tokee - To explain the issue a bit more, my understanding is that OS X uses BSD mktemp and date, so this likely might be an issue for other *BSD platforms. I'm not necessarily expecting a fix here because I was able to come up with a workaround, so I'm mostly filing the issue as potential documentation for future OS X users to reference as needed.

My workaround (which is probably not [yet] suitable as a patch) still uses (and expects) GNU coreutils. In my case, I'm using the Homebrew package manager, and installing that package is pretty easy: brew install coreutils. Homebrew symlinks the coreutils binaries on its default path with a g prefix to prevent accidental conflicts of using the GNU versions instead of the BSD versions. The workaround itself just changes all references of mktemp to gmktemp and date to gdate.

I see now that Homebrew also installs unprefixed binaries to another directory not on the default path, meaning that something like the following would probably work for another Mac user with coreutils installed with Homebrew:

PATH="/usr/local/opt/coreutils/libexec/gnubin:$PATH" ./quack.sh input-dir output-dir

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