Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/bash/18.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
在将kotlin程序编译为java jar并在控制台中打印参数[0]之后,如何在bash中转义*multiply符号? 我的bash版本 $bash--版本 GNU bash,版本4.4.23(1)-发行版(x86_64-pc-msys) 我的java版本 我的kotlinc版本 我试过的 $echo* chap_six.kt clean.sh hello.jar hello.kt README.md start.sh 我的简单打印程序_Java_Bash_Kotlin_Escaping - Fatal编程技术网

在将kotlin程序编译为java jar并在控制台中打印参数[0]之后,如何在bash中转义*multiply符号? 我的bash版本 $bash--版本 GNU bash,版本4.4.23(1)-发行版(x86_64-pc-msys) 我的java版本 我的kotlinc版本 我试过的 $echo* chap_six.kt clean.sh hello.jar hello.kt README.md start.sh 我的简单打印程序

在将kotlin程序编译为java jar并在控制台中打印参数[0]之后,如何在bash中转义*multiply符号? 我的bash版本 $bash--版本 GNU bash,版本4.4.23(1)-发行版(x86_64-pc-msys) 我的java版本 我的kotlinc版本 我试过的 $echo* chap_six.kt clean.sh hello.jar hello.kt README.md start.sh 我的简单打印程序,java,bash,kotlin,escaping,Java,Bash,Kotlin,Escaping,我试图应用中的建议,但也失败了 我的hello.sh 以及尝试 $ ./hello.sh .git $ ./hello2.sh .git 我的hello2.sh也会失败 以及尝试 $ ./hello.sh .git $ ./hello2.sh .git 我的商店看起来像这样 我的set-o看起来像这样 这不是一个解决方案,而是一种界定问题根源的手段 让我们在Bash中创建hello.sh,比较它如何处理参数数组 #/usr/bin/env bash #你好,上海 回音“$1” 现在

我试图应用中的建议,但也失败了

我的
hello.sh
以及尝试

$ ./hello.sh
.git
$ ./hello2.sh 
.git
我的
hello2.sh
也会失败 以及尝试

$ ./hello.sh
.git
$ ./hello2.sh 
.git
我的商店看起来像这样 我的set-o看起来像这样
这不是一个解决方案,而是一种界定问题根源的手段

让我们在Bash中创建
hello.sh
,比较它如何处理参数数组

#/usr/bin/env bash
#你好,上海
回音“$1”
现在创建一个
test.sh
来比较Kotlin和Bash中相同hello的输出:

#/usr/bin/env bash
对于“*”\*“*”“*””中的arg;做
kotlinout=“$(java-jar hello.jar$arg)”
bashout=“$(bash hello.sh$arg)”
如果[“$kotlinout”=“$bashout”];然后
comp='y's same';
其他的
comp='differences!!'
fi
printf'参数:%s\tKotink和Bash输出%s\n'$arg”“$comp”;
printf'Kotlin输出:%s\n'$Kotlin输出';
printf'Bash输出:%s\n'$bashot';
完成
以下是它在我的环境中的作用:

$bash test.sh
参数:*Kotink和Bash输出相同
Kotlin输出:第六章.kt
Bash输出:chap_six.kt
参数:\*Kotink和Bash输出相同
Kotlin输出:\*
Bash输出:\*
参数:'*'Kotink和Bash输出相同
Kotlin输出:'*'
Bash输出:'*'
参数:“*”Kotink和Bash输出相同
Kotlin输出:“*”
Bash输出:“*”

您是否也尝试过
“*”
“\*”
?@linosays>是的,我用新的失败尝试更新了我的问题请查看链接,特别是可能会有所帮助you@LinosaysReinstateMonica我尝试了set-f和set+f,但它不适用于java程序,我用失败的尝试更新了我的问题扫描您给出的
shopt
set-o
的输出?
$ java -jar hello.jar *
chap_six.kt
$ java -jar hello.jar \*
.git
$ java -jar hello.jar "*"
.git
$ java -jar hello.jar "\*"
\$Recycle.Bin
#!/bin/bash
FOO="*"
set +f
GLOBIGNORE=*
java -jar hello.jar $FOO
$ ./hello.sh
.git
#!/bin/bash
FOO="*"
set -f
java -jar hello.jar $FOO
$ ./hello2.sh 
.git
$ shopt
autocd          off
cdable_vars     off
cdspell         off
checkhash       off
checkjobs       off
checkwinsize    off
cmdhist         on
compat31        off
compat32        off
compat40        off
compat41        off
compat42        off
compat43        off
completion_strip_exe    off
complete_fullquote      on
direxpand       off
dirspell        off
dotglob         off
execfail        off
expand_aliases  on
extdebug        off
extglob         off
extquote        on
failglob        off
force_fignore   on
globasciiranges off
globstar        off
gnu_errfmt      off
histappend      off
histreedit      off
histverify      off
hostcomplete    on
huponexit       off
inherit_errexit off
interactive_comments    on
lastpipe        off
lithist         off
login_shell     off
mailwarn        off
no_empty_cmd_completion off
nocaseglob      off
nocasematch     off
nullglob        off
progcomp        on
promptvars      on
restricted_shell        off
shift_verbose   off
sourcepath      on
xpg_echo        off
$ set -o
allexport       off
braceexpand     on 
emacs           on
errexit         off
errtrace        off
functrace       off
hashall         on
histexpand      on
history         on
igncr           off
ignoreeof       off
interactive-comments    on
keyword         off
monitor         on
noclobber       off
noexec          off
noglob          off
nolog           off
notify          off
nounset         off
onecmd          off
physical        off
pipefail        off
posix           off
privileged      off
verbose         off
vi              off
xtrace          off