0
리눅스 쉘 스크립트의 논리 OR 오류 :내가 인쇄 도서에 대한 쉘 스크립트를 작성했습니다
나는 "인쇄 책"파일에이 코드를 저장하고 좋아하는 실행#!/bin/sh
if [ -z "$1" ]
then
exit 1
fi
filename=$1
options=""
mode="color"
first=""
last=""
pages="All pages from"
shift
until [ -z "$1" ]
do
if [ $1 = "gray" -o $1 = "grey" -o $1 = "grayscale" -o $1 = "greyscale" ]
then
options=" -o ColorModel=KGray"
mode=$1
elif [ $1 = "from" ]
then
shift
first="$1"
elif [ $1 = "to" ]
then
shift
last="$1"
fi
shift
done
if [ $first -o $last ]
then
pages="Pages"
if [ $first ]
then
pages="$pages $first"
first=" -f $first"
else
pages="$pages 1"
fi
if [ $last ]
then
pages="$pages to $last"
last=" -l $last"
else
pages="$pages to last"
fi
pages="$pages from"
fi
echo -n "$pages $filename will be printed in $mode mode. If it's OK, put paper in your printer and press ENTER. Else press CTRL+C. "
read ack
pdftops$first$last -expand $filename - | psbook | psnup -2 > tmp.ps
psselect -o tmp.ps | lpr$options
echo -n "Wait for the end of printing, then take printed pages, put them back in printer to print on other side and press ENTER again."
read ack
psselect -e -r tmp.ps | lpr$options
rm tmp.ps
exit 0
:
print-book test.pdf gray
Pages 1 to last from test.pdf will be printed in gray mode. If it's OK, put paper in your printer and press ENTER. Else press CTRL+C
즉 조건 "$ 먼저 지난 $를 -o"사실 :
나는이 있어요. 그러나이 위치에서 "$ first"와 "$ last"를 따로 확인하면 둘 다 거짓입니다.
어떻게 가능합니까? $first
및 $last
가 비어있는 경우
POSIX 표준에서는 바로이 이유 때문에'-o'를 사용하지 말 것을 권장합니다.'[...] || [...]'대신 '[... -o ...]'. – chepner