/bin/sh: 'モジュール'の関数定義の取得中にエラーが発生しました。

/bin/sh: 'モジュール'の関数定義の取得中にエラーが発生しました。

今スクリプトがありますが、常にエラーと表示されます。

stderr=/bin/sh: module: line 1: syntax error: unexpected end of file /bin/sh: error importing function definition for基準寸法」

#!/bin/sh
#
# pgp.sh
# Script to take PGP Command Line 6.5.8 (Freeware) output from PGPPackageService
# or PGPUnpackageService and execute the appropriate GnuPG commands 
#
if [ "$9" = "-se" ]
then MODE="encrypt_and_sign"
fi
if [ "$9" = "-e" ]
then MODE="encrypt_only"
fi
if [ "$8" = "-o" ]
then MODE="decrypt"
fi
#
case "$MODE" in
    "encrypt_and_sign")
        #
        # Logic for encrypt and sign
        #
        if [ "$6" = "+armor=on" ];
            then
                OPTIONS='--armor '$OPTIONS
        fi
        if [ "$7" = "+textmode=on" ];
            then
                OPTIONS='--textmode '$OPTIONS
        fi
        PASS=${15}
        OUTFILE=${17}
        USER=${13}
        REMOTE=${11}
        INFILE=${10}
        #Original script from Bryce
        #echo "$PASS" | "gpg $OPTIONS --no-tty --output $OUTFILE --passphrase-fd 0 -u $USER -r $REMOTE --sign --encrypt $INFILE"
        #script from Tyn, removed --passphrase-fd 0 and echo and double quotes
        #03252015: Tyn: Added --trust-model always for newly imported keys to be usable
        /usr/bin/gpg --trust-model always $OPTIONS --no-tty --output $OUTFILE -u $USER -r $REMOTE --sign --encrypt $INFILE

    ;;
    "encrypt_only")
        #
        # Logic for encrypt
        #
        if [ "$6" = "+armor=on" ];
            then
                OPTIONS='--armor '$OPTIONS
        fi
        if [ "$7" = "+textmode=on" ];
            then
                OPTIONS='--textmode '$OPTIONS
        fi
        OUTFILE=${13}
        REMOTE=${11}
        INFILE=${10}
        #original script from Bryce
        #echo "$PASS" | "gpg $OPTIONS --no-tty --output $OUTFILE --passphrase-fd 0 -r $REMOTE --encrypt $INFILE"
        #script from Tyn, removed --passphrase-fd 0 and echo and double quotes
        #03252015: Tyn: Added --trust-model always for newly imported keys to be usable
        /usr/bin/gpg --trust-model always $OPTIONS --no-tty --output $OUTFILE -r $REMOTE --encrypt $INFILE
    ;;
    "decrypt")
        #
        # Logic for decrypt
        #
        PASS=${7}
        OUTFILE=${9}
        INFILE=${5}
        #Original script from Bryce
        #echo "$PASS" | "gpg --no-tty --output $OUTFILE --passphrase-fd 0 --decrypt $INFILE"
        #script from Tyn, removed --passphrase-fd 0 and echo and double quotes
        #03252015: Tyn: Added --trust-model always for newly imported keys to be usable
        /usr/bin/gpg --trust-model always --no-tty --output $OUTFILE --decrypt $INFILE
    ;;
esac

ベストアンサー1

あなたの環境には、次のようにエクスポートされた関数が破損しているようです(関数にセミコロンと閉じた中括弧がありません)。

$ env "BASH_FUNC_foo%%"="() {  echo foo" bash -c "echo blah"
bash: foo: line 1: syntax error: unexpected end of file
bash: error importing function definition for `foo'
blah

Bashは環境を介して関数をエクスポートし、そこから自動的に読み込みます。もちろん、構文エラーがあれば文句を言います。最初もそうしますsh。これは、次の単純なスクリプトを実行すると同じエラーが発生することを意味します。

#!/bin/sh
echo hello

このようなものを使用して、環境に何があるかを確認できますenv | grep module(接頭辞BASH_FUNC_と接尾辞が%%異なる場合があります)。次に、その環境変数が設定されている場所を探す必要があります。ただし、Bashスクリプトでこれを設定するのは%シェル変数名に有効な文字ではないため、やや難しいです。

おすすめ記事