From 7e824c8dd7010e558f319f73a7ffaf76f95a410f Mon Sep 17 00:00:00 2001 From: Mathias Bynens Date: Tue, 26 Mar 2013 15:22:58 +0100 Subject: .functions: Print trailing newlines when not piping the output --- .functions | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/.functions b/.functions index 6b0857f..90373ae 100644 --- a/.functions +++ b/.functions @@ -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 -- cgit v1.2.3