Skip to content

Commit

Permalink
More robust path handling, update copyright/license, bump version
Browse files Browse the repository at this point in the history
Signed-off-by: Christian Blichmann <mail@blichmann.eu>
  • Loading branch information
cblichmann committed Feb 14, 2017
1 parent b0a8859 commit 6ebf39e
Show file tree
Hide file tree
Showing 3 changed files with 63 additions and 15 deletions.
19 changes: 10 additions & 9 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -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

Expand All @@ -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.
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -108,8 +108,8 @@ Bugs
Copyright/License
-----------------

headline.sh version 0.1
Copyright (c)2015,2016 Christian Blichmann <headline-sh@blichmann.eu>
headline.sh version 0.2
Copyright (c)2015-2017 Christian Blichmann <headline-sh@blichmann.eu>

headline.sh is licensed under a two-clause BSD license, see the LICENSE file
for details.
for details.
53 changes: 50 additions & 3 deletions headline.sh
Original file line number Diff line number Diff line change
@@ -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;
Expand Down

0 comments on commit 6ebf39e

Please sign in to comment.