]> granicus.if.org Git - cgit/commitdiff
syntax-highlight: when the file has no extension, assume text
authorFerry Huberts <ferry.huberts@pelagic.nl>
Tue, 9 Oct 2012 11:10:48 +0000 (13:10 +0200)
committerJason A. Donenfeld <Jason@zx2c4.com>
Tue, 9 Oct 2012 11:19:12 +0000 (13:19 +0200)
There are 2 situations:
1- empty extension: assuming text is better than highlight
   producing no output because of a missing argument.
2- no extension at all: assuming text is better than setting
   the extension to the filename, which is what now happens.

Signed-off-by: Ferry Huberts <ferry.huberts@pelagic.nl>
filters/syntax-highlighting.sh

index 0639b100e7fb6e44cf272eddd5d1ce46bfbdfeba..47f626782a579f4c051230db104a4bbda49f1fbd 100755 (executable)
 BASENAME="$1"
 EXTENSION="${BASENAME##*.}"
 
+[ "${BASENAME}" = "${EXTENSION}" ] && EXTENSION=txt
+[ -z "${EXTENSION}" ] && EXTENSION=txt
+
 # map Makefile and Makefile.* to .mk
-[ "${BASENAME%%.*}" == "Makefile" ] && EXTENSION=mk
+[ "${BASENAME%%.*}" = "Makefile" ] && EXTENSION=mk
 
 # highlight versions 2 and 3 have different commandline options. Specifically,
 # the -X option that is used for version 2 is replaced by the -O xhtml option