Skip to content

Commit

Permalink
update view.sh to improve multiple os support:
Browse files Browse the repository at this point in the history
1. use /usr/bin/env to locate bash instead of /usr/bin/bash
2. write a version compare function in shell syntax to avoid the
   dependence on vercmp program.
  • Loading branch information
foxsen authored and yetist committed Aug 26, 2022
1 parent 0e2c9ad commit f52b6fe
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions view.sh
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
#!/usr/bin/bash
#!/usr/bin/env bash

verlte() {
[ "$1" = "`echo -e "$1\n$2" | sort -V | head -n1`" ]
}

ver=`hugo version|awk '{print $2}'`
version=${ver#v*}
result=`vercmp $version 0.7`

if [ $result -gt 0 ]; then
if verlte 0.7 $version ; then
hugo --printI18nWarnings --disableFastRender --ignoreCache server
else
hugo --i18n-warnings --disableFastRender --ignoreCache server
Expand Down

0 comments on commit f52b6fe

Please sign in to comment.