为什么我的使用卷曲/智能引号的shell命令不起作用? [英] Why doesn't my shell command using curly/smart quotes work?

查看:93
本文介绍了为什么我的使用卷曲/智能引号的shell命令不起作用?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我编写了以下shell脚本:

I have written the following shell script:

#!/bin/bash
total=0
echo "Please enter 10 numbers >"
read VAR1 VAR2 VAR3 VAR4 VAR5 VAR6 VAR7 VAR8 VAR9 VAR10
total=$((VAR1+VAR2+VAR3+VAR4+VAR5+VAR6+VAR7+VAR8+VAR9+VAR10))
echo $total

在命令行命令中运行回显,例如(如下所示)呼应"fine"一词

Running echo in the command line command e.g. (see below) echoes the phrase fine

echo "Please enter 10 numbers >"

但是当我尝试运行shell脚本时,不会回显文本.该脚本有效,如果我运行它并输入10个数字,则返回正确的总数,但是如果您不知道输入数字,这将没有用! 我已经通过运行再次检查了/bin/bash是否正确

But when I try to run the shell script the text isn't echoed. The script works, if I run it and type in 10 numbers the correct total is returned, but this is not useful if you don't know to type in the numbers! I have double checked that /bin/bash is correct by running

echo $SHELL

它返回/bin/bash,所以我不确定可能是什么问题.

which returns /bin/bash so I'm not sure what the problem might be.

推荐答案

这是由于使用引号"引起的,这些引号实际上对您的shell没有语法含义.因此,>会将echo命令的输出重定向到名为的文件中.

This is caused by using "quotes" that don't actually have syntactic meaning to your shell. Consequently, >" is redirecting the output of your echo command into a file named ".

转到系统偏好设置",然后转到键盘".选择文本"标签,然后取消选中使用智能引号和破折号".

Go to "System Preferences", then to "Keyboard". Select the "Text" tab, then uncheck "Use smart quotes and dashes".

不要使用Office应用程序来编辑代码,也不要通过Outlook或类似工具邮寄代码.就是说,如果您必须将代码键入Office应用而又不被修改,请输入自动更正"选项;选择自动套用格式"标签,然后取消选中带智能引号的直引号"

Don't use Office apps to edit code, and don't mail code through Outlook or similar. That said, if you must type code into an Office app without it being munged, enter AutoCorrect options; select the AutoFormat tab, and uncheck "Straight quotes with smart quotes"

这篇关于为什么我的使用卷曲/智能引号的shell命令不起作用?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆