量角器 conf.js 仅在 运行 通过批处理脚本的变量时给出 'no specs found'

Protractor conf.js gives 'no specs found' only when run through batch script's variable

我正在将一个字符串(存储在另一个文件中的文件的名称)读取到 bash 脚本中的一个变量。
我对 运行 的原始命令是

protractor conf.js --specs 'LeadershipBoard.js'

如果直接写在脚本文件中效果很好。但是以下不起作用。

protractor conf.js --specs $value 

和returns "No specs found. Finished in 0 seconds"。这是我的 RunConf.sh 文件

#!/bin/bash
value=$(<string.txt)
echo $value           // 'LeadershipBoard.js'

commandForConf="protractor conf.js --specs $value"
echo $commandForConf  // protractor conf.js --specs 'LeadershipBoards.js'

eval "$commandForConf"   // No specs found
eval "protractor conf.js --specs  'LeadershipBoard.js'"   // 6 specs found, 0 failures

我想让 eval "$commandForConf" 起作用。这是控制台上的日志

$ sh RunConf.sh  
'LeadershipBoard.js'  
protractor conf.js --specs 'LeadershipBoard.js'  
[15:49:35] I/hosted - Using the selenium server at http://localhost:4444/wd/hub   
[15:49:35] I/launcher - Running 1 instances of WebDriver  
Started  

No specs found Finished in 0 seconds  

[15:49:46] I/launcher - 0 instance(s) of WebDriver still running  
[15:49:46] I/launcher - internet explorer11 #01 passed  
[15:49:54] I/hosted - Using the selenium server at http://localhost:4444/wd/hub  
[15:49:54] I/launcher - Running 1 instances of WebDriver Started  


6 specs, 0 failures Finished in 58.478 seconds  
[15:51:00] I/launcher - 0 instance(s) of WebDriver still running  
[15:51:00] I/launcher - internet explorer11 #01 passed  

我发现错误来自文件 "string.txt",我将数据从 HTML 另存为文件 js 函数保存到该文件。它有一个奇怪的字符,在 shell 的回显或记事本文本中没有显示。

当我看到那个字符时,我尝试在批处理文件中重复这些步骤。我使用 js 正则表达式删除了字符。那解决了问题。