Rscript 表现不佳

Rscript 表现不佳

这有效:

TMPDIR="/tmp/___"
export TMPDIR
mkdir -p "$TMPDIR"
script="$TMPDIR"/myscript
cat <<'EOF' > "$script"                                                                       
#!/usr/bin/Rscript --vanilla --slave                                                          
EOF                                                                                           

chmod 755 "$script"
ls -l "$script"
"$script"
ls -l "$script"

这将删除$script并归档“/tmp如果您有重要内容,请勿运行此程序” /tmp

TMPDIR="/tmp/   "
export TMPDIR
mkdir -p "$TMPDIR"
script="$TMPDIR"/myscript
cat <<'EOF' > "$script"                                                                       
#!/usr/bin/Rscript --vanilla --slave                                                          
EOF                                                                                           

chmod 755 "$script"
ls -l "$script"
"$script"
ls -l "$script"

它们之间的区别仅在于$TMPDIR包含空格。

造成这种行为差异的原因是什么?

$ Rscript --version
R scripting front-end version 4.1.2 (2021-11-01)
$ cat /etc/issue.net 
Ubuntu 22.04.1 LTS

它看起来越来越像一个错误。如果从源代码编译 R 并设置 TMPDIR=" ":

:
make[3]: Entering directory '/tmp/R-devel/src/library/profile'
building system startup profile
make[3]: Leaving directory '/tmp/R-devel/src/library/profile'
make[3]: Entering directory '/tmp/R-devel/src/library/translations'
building package 'translations'
make[4]: Entering directory '/tmp/R-devel/src/library/translations'
make[4]: Leaving directory '/tmp/R-devel/src/library/translations'
make[3]: Leaving directory '/tmp/R-devel/src/library/translations'
make[3]: Entering directory '/tmp/R-devel/src/library/base'
building package 'base'
make[4]: Entering directory '/tmp/R-devel/src/library/base'
/bin/bash: line 9:  /R3273656: No such file or directory
/bin/bash: line 12:  /R23273656: No such file or directory
cmp:  /R23273656: No such file or directory
mv: cannot stat ' /R23273656': No such file or directory
make[4]: *** [../../../share/make/basepkg.mk:65: mkRbase] Error 1
make[4]: Leaving directory '/tmp/R-devel/src/library/base'
make[3]: *** [Makefile:31: all] Error 2
make[3]: Leaving directory '/tmp/R-devel/src/library/base'
make[2]: *** [Makefile:37: R] Error 1
make[2]: Leaving directory '/tmp/R-devel/src/library'
make[1]: *** [Makefile:28: R] Error 1
make[1]: Leaving directory '/tmp/R-devel/src'
make: *** [Makefile:62: R] Error 1

另外,将 sysutils.c:1893 中的 TMPDIR 更改为 DUMMY 可以使问题消失。

相关内容