0

如果我在自己的终端中运行代码

  sh projectbingo.sh 

它显示为:

Hello World

hi

当我运行以下代码时:

 gnome-terminal  --window-with-profile=tushar -x ./projectbingo.sh

一个新的终端弹出,但显示:

./projectbingo.sh: line 3: $'\E[H\E[2J': command not found
./projectbingo.sh: line 23: $'\E[H\E[2J': command not found
./projectbingo.sh: line 77: $'\E[H\E[2J': command not found
Got bus address:  "unix:abstract=/tmp/dbus-  3G1IPFUIn6,guid=85293fb9a05e2828c07c371800000364" 
Connected to accessibility bus at:  "unix:abstract=/tmp/dbus-    3G1IPFUIn6,guid=85293fb9a05e2828c07c371800000364" 
 Registered DEC:  true 
./projectbingo.sh: line 79: $'\E[H\E[2J': command not found  
Got bus address:  "unix:abstract=/tmp/dbus-3G1IPFUIn6,guid=85293fb9a05e2828c07c371800000364" 
Connected to accessibility bus at:  "unix:abstract=/tmp/dbus-3G1IPFUIn6,guid=85293fb9a05e2828c07c371800000364" 
Registered DEC:  true 
./projectbingo.sh: line 82: $'\E[H\E[2J': command not found
./projectbingo.sh: line 107: $'\E[H\E[2J': command not found
Got bus address:  "unix:abstract=/tmp/dbus-3G1IPFUIn6,guid=85293fb9a05e2828c07c371800000364" 
Connected to accessibility bus at:  "unix:abstract=/tmp/dbus-3G1IPFUIn6,guid=85293fb9a05e2828c07c371800000364" 
Registered DEC:  true 
./projectbingo.sh: line 110: $'\E[H\E[2J': command not found
./projectbingo.sh: line 116: $'\E[H\E[2J': command not found
 Hello World\n\nhi

请帮忙 !!!

4

2 回答 2

1

这不是终端问题。我怀疑是外壳问题。

具体来说,该$'...'符号是特定于 bash 的扩展,但您只是通过shand not运行脚本bash,因此它不适用。

尝试将脚本中的 shebang 行更改为

#!/bin/bash
于 2012-11-10T11:12:58.650 回答
0

这不是特定于 shell 的问题。我不知道为什么会这样......但是当我使用

   echo -e "Hello World\nHi"

它有效但是当我尝试运行 sh projectbingo.sh 它显示

-e 你好世界你好

所以我的问题得到了解决,但导致了新问题的到来

于 2012-11-10T13:25:03.610 回答