New version v1.1 is out with a bug fix and BSD support! The porting was not hard, but I felt like writing about it either way.
So I used the crystal preprocessor to call POSIX commands on Linux and Powershell ones on Windows.
if Data.output_mode == :pdf || Data.output_mode == :latex {% if flag?(:linux) %} abort "xelatex not found" if `which xelatex`.empty? {% else %} if `powershell -command "get-command ptts -ErrorAction silentlyContinue"`.empty? abort "xelatex not found" end {% end %} end
This of course breaks stuff on all other systems, so I changed it to:
if Data.output_mode == :pdf || Data.output_mode == :latex {% unless flag?(:windows) %} abort "xelatex not found" if `which xelatex`.empty? {% else %} if `powershell -command "get-command ptts -ErrorAction silentlyContinue"`.empty? abort "xelatex not found" end {% end %} end
Way better!
In newer versions of crystal, you use the following function to determine whether a file exists:
File::Info.readable? "filename"
FreeBSD however ships version 1.10.1, where you use just:
File.readable? "filename"
I solved this problem with the following:
{% if compare_versions(Crystal::VERSION, "1.13.0") == -1 %} abort "file not readable: #{filename}" unless File.readable? filename {% else %} abort "file not readable: #{filename}" unless File::Info.readable? filename {% end %}
It might break in some versions, but it compiled on Debian, so i should not be problem on linux machines.
FreeBSD does not have '/usr/share/fonts/' so I added a check if a font directory exists, which sould have been there from the start.
I renamed the 'install-linux.sh' to 'install-unix.sh' and it now tells you where it installed the program in case it's not in your $PATH.
I also had to recompile the Windows version, which is documented here.