From 5f965672c7a24c07b0f2dde55c943e1b228dacba Mon Sep 17 00:00:00 2001 From: Taiki Sugawara Date: Sat, 9 Apr 2022 01:37:14 +0900 Subject: [PATCH] change COW_FILE detection from OSTYPE to checking execution results --- bin/unko.say | 13 +++++-------- bin/unko.think | 13 +++++-------- 2 files changed, 10 insertions(+), 16 deletions(-) diff --git a/bin/unko.say b/bin/unko.say index 4e7f134..49dee64 100755 --- a/bin/unko.say +++ b/bin/unko.say @@ -9,13 +9,10 @@ readonly THIS_DIR LIB_DIR="${THIS_DIR}/../lib/super_unko" readonly LIB_DIR -case ${OSTYPE} in - darwin*) - COW_FILE="${LIB_DIR}/unko_mb.cow" - ;; - *) - COW_FILE="${LIB_DIR}/unko.cow" - ;; -esac +COW_FILE="${LIB_DIR}/unko_mb.cow" +if ! (cowsay -f "${COW_FILE}" 'うんこ' | grep -qe 'うんこ' && + cowsay -f "${COW_FILE}" 'もりもり' | grep -qe '💩'); then + COW_FILE="${LIB_DIR}/unko.cow" +fi cowsay -f "${COW_FILE}" "$@" diff --git a/bin/unko.think b/bin/unko.think index de6b08d..436fd58 100755 --- a/bin/unko.think +++ b/bin/unko.think @@ -9,13 +9,10 @@ readonly THIS_DIR LIB_DIR="${THIS_DIR}/../lib/super_unko" readonly LIB_DIR -case ${OSTYPE} in - darwin*) - COW_FILE="${LIB_DIR}/unko_mb.cow" - ;; - *) - COW_FILE="${LIB_DIR}/unko.cow" - ;; -esac +COW_FILE="${LIB_DIR}/unko_mb.cow" +if ! (cowsay -f "${COW_FILE}" 'うんこ' | grep -qe 'うんこ' && + cowsay -f "${COW_FILE}" 'もりもり' | grep -qe '💩'); then + COW_FILE="${LIB_DIR}/unko.cow" +fi cowthink -f "${COW_FILE}" "$@"