From 0adaf05483dd196e0090cfe7145d0317f41213d6 Mon Sep 17 00:00:00 2001 From: alban Date: Wed, 3 Jun 2020 20:52:22 +0200 Subject: [PATCH] [enh] It should be able to read from piped content --- changelog.sh | 25 ++++++++++++++++++------- 1 file changed, 18 insertions(+), 7 deletions(-) diff --git a/changelog.sh b/changelog.sh index fa37754..7a3a554 100755 --- a/changelog.sh +++ b/changelog.sh @@ -4,7 +4,9 @@ APP_PATH=$( cd $(dirname ${BASH_SOURCE[0]}) && pwd ) APP_NAME=$( basename ${BASH_SOURCE[0]}) - +STDIN=$( cat ) +ls -lh /proc/self/fd +exec 0 "$CHANGELOG" -# parse command -change "$ENTRY_FILE" +# Detect piped content +if [[ -n "$STDIN" ]] ; then + echo -e "$STDIN" > $ENTRY_FILE -[[ $? -eq 0 ]] && exit +#OR enter interactive mode +else + change "$ENTRY_FILE" +fi +# confirm the output +echo -e "\nHere is the content you are about to add:\n\n$(cat $ENTRY_FILE)\n" +read -e -p "OK? [Yn]: " -i y RETURN +[[ "N" == ${RETURN^^} ]] && exit 1 + +# Send data to outputs for (( i=0; i<${#PLUGIN_OUTPUT_MENU[@]}; i++)) ; do echo "${PLUGIN_OUTPUT_MENU[$i]}" ${PLUGIN_OUTPUT[$i]} $ENTRY_FILE