希望大家都做得很好。我是Linux Shell脚本的新手。我正在尝试学习基本的shell脚本,我从其他条件入手,并且从一个星期开始就陷入其中。我已经阅读了尽可能多的文章,但是我不明白这里存在的问题。我知道这对于你们来说必须是非常基础的,但是请帮助我:)
这是我写的脚本
const items = [
{
name: "Fruits",
id: 0,
children: [{
name: "Apple",
id: 10,
},{
name: "Strawberry",
id: 17,
},{
name: "Pineapple",
id: 13,
},{
name: "Banana",
id: 14,
},{
name: "Watermelon",
id: 15,
},{
name: "Kiwi fruit",
id: 16,
}]
}]
export default class TestScreen extends Component {
constructor(){
super()
this.state = {
selectedItems: [],
modalVisible: false,
}
}
setModalVisible(visible) {
this.setState({modalVisible: visible});
}
onSelectedItemsChange = (selectedItems) => {
this.setState({ selectedItems });
console.log(selectedItems)
}
openModal = () => {
return(
<SafeAreaView style={{flex:1}}>
<View style={{width:300, height:400, backgroundColor:'red'}}>
<Modal
animationType="slide"
transparent={false}
visible={this.state.modalVisible}
onRequestClose={() => {
Alert.alert('Modal has been closed.');
}}>
<View style={{marginTop: 22}}>
<View>
<Text>Hello World!</Text>
<TouchableHighlight
onPress={() => {
this.setModalVisible(!this.state.modalVisible);
}}>
<Text>Hide Modal</Text>
</TouchableHighlight>
</View>
</View>
</Modal>
<TouchableHighlight
onPress={() => {
this.setModalVisible(true);
}}>
<Text>Show Modal</Text>
</TouchableHighlight>
</View>
</SafeAreaView>
)
}
render() {
return (
<SafeAreaView style={{flex:1}}>
<View>
<SectionedMultiSelect
items={items}
uniqueKey='id'
subKey='children'
selectText='Choose some things...'
showDropDowns={true}
readOnlyHeadings={true}
onSelectedItemsChange={this.onSelectedItemsChange}
selectedItems={this.state.selectedItems}
//Here I call the openModal function but nothing appears
onConfirm={()=> {this.openModal}}
/>
</View>
</SafeAreaView>
);
}
}
执行此脚本时,出现错误提示。
#!/bin/sh count=102 if [$count -gt 100] then echo "$count is greater than 100" else echo "$count is less than 100" fi
*我还尝试了不仅使用整数而且使用字符串进行用户输入,仍然遇到相同的错误。请帮助:)
提前谢谢
答案 0 :(得分:2)
您需要在[
之后和]
之前提供空间。对于例如
[ $count -gt 100 ]
示例代码:
count=102
if [ $count -gt 100 ]
then
echo "$count is greater than 100"
else
echo "$count is less than 100"
fi