私はちょうどbashマニュアルでこのスニペットを見つけました:
A variable may be assigned to by a statement of the form
name=[value]
If value is not given, the variable is assigned the null string.
とは正確にはどういう意味null stringですか? 例えば
local empty
に相当
local empty=""
?
私はちょうどbashマニュアルでこのスニペットを見つけました:
A variable may be assigned to by a statement of the form
name=[value]
If value is not given, the variable is assigned the null string.
とは正確にはどういう意味null stringですか? 例えば
local empty
に相当
local empty=""
?
「ヌル文字列」とは、長さがゼロの文字列です。あなたの例では、両方とも同じです。
簡単なテスト:
#!/bin/bash
go(){
local empty
local empty2=""
[[ -z $empty ]] && echo "empty is null"
[[ -z $empty2 ]] && echo "empty2 is null"
[[ $empty == $empty2 ]] && echo "They are the same"
}
go
プリント:
empty is null
empty2 is null
They are the same