while getopts "hd:R:" arg; do
case $arg in
h)
echo "usgae"
;;
d)
dir=$OPTARG
;;
R)
if [[ $OPTARG =~ ^[0-9]+$ ]];then
level=$OPTARG
else
level=1
fi
;;
\?)
echo "WRONG" >&2
;;
esac
done
Run Code Online (Sandbox Code Playgroud)
level是指参数-R,dir是指参数-d
当我输入 ./count.sh -R 1 -d test/它正确的工作
当我输入./count.sh -d test/ -R 1它正确的工作
但我想在输入./count.sh -d test/ -R或输入时使其工作./count.sh -R -d test/
这意味着我想要-R一个默认值,命令序列可以更灵活.
我使用markdown写笔记,当我想添加图片时,我这样做:

这是一个问题,当我git push回购时,github无法识别
我电脑里的绝对路径
所以我的问题是github和markdown文件中的图片路径是什么?
istream &func(istream &in)
{
string data;
while (in >> data, !in.eof()) {
if (in.bad())
throw runtime_error("IO stream corrupted");
if (in.fail()) {
cerr << "bad data, try again" << endl;
in.clear();
in.ignore(200);
continue;
}
cout << data << endl;;
}
//in.clear(istream::eofbit | istream::failbit);
in.clear();
return in;
}
Run Code Online (Sandbox Code Playgroud)
为什么in.clear(istream::eofbit | istream::failbit);不能重置cin?
但in.clear可以做到.
PS:我在main()中使用此函数,并将cin其用作参数.
这是我的代码:
if [ $value == "^[[:digit:]]*$" ]
then
echo "number"
else
echo "other"
fi
Run Code Online (Sandbox Code Playgroud)
即使我设置,程序似乎也不会回应"数字" value=1.