delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2008/07/22/17:33:50

X-Recipient: archive-cygwin AT delorie DOT com
X-Spam-Check-By: sourceware.org
X-IronPortListener: Outbound_SMTP
MIME-Version: 1.0
Subject: RE: Re: lpr works? FAQ in error?
Date: Tue, 22 Jul 2008 17:33:05 -0400
Message-ID: <31DDB7BE4BF41D4888D41709C476B6570929B1FA@NIHCESMLBX5.nih.gov>
In-Reply-To: A<ml59841anhmn21j3b0e83mk0hpnonb0rm7@4ax.com>
References: <380-2200855974950906 AT cantv DOT net> <loom DOT 20080717T220746-843 AT post DOT gmane DOT org> <g5ov52$9pm$1 AT ger DOT gmane DOT org> <9a498418e4cd1ia8ll54i7eqiehdjmq0m5 AT 4ax DOT com> A<ml59841anhmn21j3b0e83mk0hpnonb0rm7 AT 4ax DOT com>
From: "Buchbinder, Barry (NIH/NIAID) [E]" <BBuchbinder AT niaid DOT nih DOT gov>
To: <cygwin AT cygwin DOT com>, "Wilfried" <wh_ng AT gmx DOT de>
X-IsSubscribed: yes
Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm
List-Id: <cygwin.cygwin.com>
List-Unsubscribe: <mailto:cygwin-unsubscribe-archive-cygwin=delorie DOT com AT cygwin DOT com>
List-Subscribe: <mailto:cygwin-subscribe AT cygwin DOT com>
List-Archive: <http://sourceware.org/ml/cygwin/>
List-Post: <mailto:cygwin AT cygwin DOT com>
List-Help: <mailto:cygwin-help AT cygwin DOT com>, <http://sourceware.org/ml/#faqs>
Sender: cygwin-owner AT cygwin DOT com
Mail-Followup-To: cygwin AT cygwin DOT com
Delivered-To: mailing list cygwin AT cygwin DOT com
X-MIME-Autoconverted: from quoted-printable to 8bit by delorie.com id m6MLXndL006626

Wilfried wrote on Monday, July 21, 2008 10:11 AM:

> Ehh, I just saw that Rodrigo Medina addressed all these problems.
> 
> So the script would probably look like this:
> 
> --------------snip-------------
> #!/bin/sh
> $1 $2 $3 $4 $5 | unix2dos > tmp_file
> cygstart notepad.exe /p tmp_file
> rm tmp_file
> --------------snip-------------

It looks to me that the command
	$1 $2 $3 $4 $5
has two or three problems:
  (1) Arguments are not quoted.
  (2) One might have more than a command and 4 arguments.
  (3) It is also possible that one may have surprises if /bin/sh is set up so when non-interactive it handles aliases and shell functions differently than expected.
So I would just pipe into the shell script.

The second place is that there is theoretically a race between cygstart and rm.  What happens if rm deleted tmp_file before notepad reads it?  I can think of two ways to handle it.  Adding
	sleep 1
to delay rm by a second will probably usually be enough of a delay.  Substituting
	"$(cygpath -u "$COMSPEC")" /c start /wait notepad.exe /p tmp_file
for
	cygstart notepad.exe /p tmp_file
to use Windows' start command will wait until notepad is closed.  (This may be longer than you want to wait.)

But I haven't tried this, so it may not work.

--------------snip--------------
#!/bin/sh
unix2dos > tmp_file
cygstart notepad.exe /p tmp_file
sleep 1
rm tmp_file
--------------snip--------------

- Barry

--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Problem reports:       http://cygwin.com/problems.html
Documentation:         http://cygwin.com/docs.html
FAQ:                   http://cygwin.com/faq/


- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019