语境

语境

语境

Catalina (zsh) 和 Homebrew:手册页成功返回pdftk&ps2pdf

目标是执行:pdfBatesStamp.sh如中所述 https://unix.stackexchange.com/a/115537/182280

我将脚本的第一行更改为:#!/bin/zsh -

观察结果

初步测试返回:

在此输入图像描述

错误:: command not foundine XX:没有命令/注释的行。屏幕截图显示第 104,105,109,111 行为空:

在此输入图像描述

更新:通过在行首放置 # 来纠正所述错误。

第 132 行:

在此输入图像描述

问题

  1. 究竟是什么导致了上述错误?
  2. 有什么补救办法?
  3. 是否有任何原因导致该脚本永远不会在上述上下文中运行?

对于 jsbillings

user@JUPITER pdfBatesStamp % ./pdfBatesStamp.sh Exhibits_ActivityReport.pdf
./pdfBatesStamp.sh:59: command not found: ^M
./pdfBatesStamp.sh:132: parse error near `elif'
user@JUPITER pdfBatesStamp % 
user@JUPITER pdfBatesStamp % sh pdfBatesStamp.sh Exhibits_ActivityReport.pdf
pdfBatesStamp.sh: line 132: syntax error near unexpected token `elif'
'dfBatesStamp.sh: line 132: `elif [ $# -eq 2 ]; then

Ubuntu 16.04测试结果:

user@azimuth:~/Desktop/BatesStamp$ cp pdfBatesStamp.sh test.sh
user@azimuth:~/Desktop/BatesStamp$ dos2unix test.sh
dos2unix: converting file test.sh to Unix format ...
user@azimuth:~/Desktop/BatesStamp$ ls
Exhibits_ActivityReport.pdf  pdfBatesStamp.sh  test.sh
user@azimuth:~/Desktop/BatesStamp$ ls -l
total 11384
-rw------- 1 user user 11589045 Nov 23 18:00 Exhibits_ActivityReport.pdf
-rwxrwxr-x 1 user user    32764 Nov 23 22:24 pdfBatesStamp.sh
-rwxrwxr-x 1 user user    32764 Nov 23 22:26 test.sh
user@azimuth:~/Desktop/BatesStamp$ ./test.sh Exhibits_ActivityReport.pdf 
Input File = "/home/user/Desktop/BatesStamp/Exhibits_ActivityReport.pdf"  (origSize=11,589,045)
(standard_in) 1: syntax error
(standard_in) 1: illegal character: M
(standard_in) 1: syntax error
(standard_in) 1: syntax error
(standard_in) 1: syntax error
./test.sh: line 384: [: too many arguments
*** Can't find page size
user@azimuth:~/Desktop/BatesStamp$ mac2unix test.sh
mac2unix: converting file test.sh to Unix format ...
user@azimuth:~/Desktop/BatesStamp$ ./test.sh Exhibits_ActivityReport.pdf 
Input File = "/home/user/Desktop/BatesStamp/Exhibits_ActivityReport.pdf"  (origSize=11,589,045)
(standard_in) 1: syntax error
(standard_in) 1: illegal character: M
(standard_in) 1: syntax error
(standard_in) 1: syntax error
(standard_in) 1: syntax error
./test.sh: line 384: [: too many arguments
*** Can't find page size

相关内容