#!/bin/bash
# exitlab
#
# example of exit status
# check for non-existent file
# exit status will be 2
# create file and check it
# exit status will be 0
#
ls xyzzy.345 > /dev/null 2>&1
status='echo $?'
echo "status is $status"
# create the file and check again
# status will not be 0
touch xyzzy.345
ls xyzzy.345 > /dev/null 2>&1
status='echo $?'
echo "status is $status"
#remove the file
rm xyzzy.345
edx.orgにはLabがあり、これはスクリプトです。私はそれを実行すると、以下のように、出力は次のようになります。Bash終了コードステータススクリプトエラー
status is echo $?
status is echo $?
私は出力が0または2.私はstatus='(echo $?)
のように括弧を入れてみましたが、それはstatus is echo $?
につながることになっていると思います。次に、一重引用符の外側に括弧を入れてみましたが、status is echo $?
という同じ出力がありました。
アイデア?
私は 'エコー$ "状態が" 使用する'や 'STT = $ ?;?エコー "ステータスは" $ stt " –