diff --git a/LICENSE b/LICENSE index 0fcf3ef..ac5d761 100644 --- a/LICENSE +++ b/LICENSE @@ -1,5 +1,5 @@ -headline.sh version 0.1 -Copyright (c)2015,2016 Christian Blichmann +headline.sh version 0.2 +Copyright (c)2015-2017 Christian Blichmann ASCII-art font renderer @@ -14,10 +14,11 @@ modification, are permitted provided that the following conditions are met: THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -ARE DISCLAIMED. IN NO EVENT SHALL CHRISTIAN BLICHMANN BE LIABLE FOR ANY -DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND -ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF -THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE +LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +POSSIBILITY OF SUCH DAMAGE. diff --git a/README.md b/README.md index 3fa987e..aa149f0 100644 --- a/README.md +++ b/README.md @@ -108,8 +108,8 @@ Bugs Copyright/License ----------------- -headline.sh version 0.1 -Copyright (c)2015,2016 Christian Blichmann +headline.sh version 0.2 +Copyright (c)2015-2017 Christian Blichmann headline.sh is licensed under a two-clause BSD license, see the LICENSE file -for details. \ No newline at end of file +for details. diff --git a/headline.sh b/headline.sh index 9500a87..60c9336 100755 --- a/headline.sh +++ b/headline.sh @@ -1,11 +1,58 @@ #!/bin/bash +# headline.sh version 0.2 +# Copyright (c)2015-2017 Christian Blichmann +# +# ASCII-art font renderer +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions are met: +# * Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# * Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in the +# documentation and/or other materials provided with the distribution. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE +# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +# POSSIBILITY OF SUCH DAMAGE. + +# Implements GNU's "readlink -f" portably. +canonical_path() +{ + file=$1 + cd $(dirname "$file") + file=$(basename "$file") + limit=0 + while [ -L "$file" -a $limit -lt 1000 ]; do + file=$(readlink "$file") + cd "$(dirname "$file")" + file=$(basename "$file") + limit=$(($limit+1)) + done + echo "$(pwd -P)/$file" +} # Change to the directory of this script. -cd "$(dirname "$0")" && cd "$(pwd -P)" +THIS=$(basename "$0") +THIS_DIR=$(dirname "$(canonical_path "$0")") +cd "$THIS_DIR" -# Source font file and build character map. HEADLINE_FONT=${HEADLINE_FONT:-shell-sans.sf} -. $HEADLINE_FONT +if [ ! -r "$HEADLINE_FONT" ]; then + >&2 echo "$THIS: cannot access font file '$HEADLINE_FONT'" + exit 2 +fi + +# Source font file and build character map. +. "$HEADLINE_FONT" declare -A HEADLINE_MAP for ((i=0;i<${#characters};i++)); do HEADLINE_MAP[${characters:i:1}]=$i;