简体   繁体   English

重击-参数不起作用

[英]Bash - argument not working

Hello I am running a javac command (lstf is a file) 您好我正在运行一个Javac命令(lstf是一个文件)

javac @$lstf

For some reason, I get an error saying javac: file not found: path/to/dir/*.java . 出于某种原因,我收到一条错误消息,指出javac: file not found: path/to/dir/*.java Whenever I type the args in manually in Terminal javac works. 每当我在Terminal javac works中手动输入args时。

Here is the code: 这是代码:

mkdir "$out"

cd src
scan

"$cc" $cflags -d "../$out" @${lstf}
rm -rf $lstf
cd ../

scan is the function that generates all the paths in the file $lstf - it works fine scan是在文件$ lstf中生成所有路径的函数-工作正常

You need to say javac @foo , and lstf = foo ? 您需要说javac @foolstf = foo吗?

Whenever you are in a situation where variable names are hard to decipher, you can use ${var} syntax instead of just $var : 每当您遇到难以解析的变量名的情况时,都可以使用${var}语法,而不仅仅是$var

javac @${lstf}

如果文件路径存储在lstf变量中,则将其命名为

javac "$lstf"

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM