Skip to content

Commit

Permalink
.functions: Print trailing newlines when not piping the output
Browse files Browse the repository at this point in the history
  • Loading branch information
mathiasbynens committed Mar 26, 2013
1 parent 8927425 commit 7e824c8
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions .functions
Original file line number Diff line number Diff line change
Expand Up @@ -103,19 +103,28 @@ function digga() {
# Escape UTF-8 characters into their 3-byte format
function escape() {
printf "\\\x%s" $(printf "$@" | xxd -p -c1 -u)
echo # newline
# print a newline unless we’re piping the output to another program
if [ -t 1 ]; then
echo # newline
fi
}

# Decode \x{ABCD}-style Unicode escape sequences
function unidecode() {
perl -e "binmode(STDOUT, ':utf8'); print \"$@\""
echo # newline
# print a newline unless we’re piping the output to another program
if [ -t 1 ]; then
echo # newline
fi
}

# Get a character’s Unicode code point
function codepoint() {
perl -e "use utf8; print sprintf('U+%04X', ord(\"$@\"))"
echo # newline
# print a newline unless we’re piping the output to another program
if [ -t 1 ]; then
echo # newline
fi
}

# Show all the names (CNs and SANs) listed in the SSL certificate
Expand Down

0 comments on commit 7e824c8

Please sign in to comment.