这个bash变量设置方式是否正确

时间:2017-07-20 10:01:47

标签: bash variables

这个bash变量设置方式是否正确?请提供一些有关此用法的深入说明。

class AnimalGroup<T> : IEnumerable<T>
    where T : Animal
{
    public IEnumerator<T> GetEnumerator() { throw new NotImplementedException(); }
    IEnumerator IEnumerable.GetEnumerator() { throw new NotImplementedException(); }
}

class AnimalGroup : AnimalGroup<Animal> { }

1 个答案:

答案 0 :(得分:1)

您可以使用此表单设置一些默认值。例如

default="/root"
read -p "What is the directory? [$default] " AA
: ${AA:=$default}  
echo "Using: $AA"

注意我在${AA:=...}中添加了冒号,以便在变量为空时进行替换,而不仅仅是取消设置(因为这里设置了)。

请参阅手册中的Shell Parameter Expansion:命令为documented here

相关问题