• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Shell script help
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Shell script help


  • Subject: Re: Shell script help
  • From: Xavier Noria <email@hidden>
  • Date: Fri, 3 Sep 2004 22:50:46 +0200

On Sep 3, 2004, at 21:15, Eric Ocean wrote:

I'm completely unfamiliar with shell scripting.

How do I invoke this script? (i.e. what parameters)

This script basically tests the output of programs passed in the command line with known output. Looks like a regression test.


#!/bin/bash
#

TMPOUT=rltest.out

Assigns "rltest.out" to the shell variable TMPOUT.

for prog; do

In each loop a parameter is assigned to the prog variable. That is, if you call the script like this


    $ bash script.sh foo bar baz

then that loop iterates three times, and prog is "foo", "bar", and "baz", respectively.

for inp in input.*; do

Iterates over the files that match the pattern input.*, as in the command line. Each corresponding filename is assigned to inp in turn.


		echo -n "$prog on $inp ... ";
		./$prog < $inp 2>&1 > $TMPOUT;

Executes $prog, which is supposed to be an executable in the current directory, passing the contents of the file named $inp by stdin, and redirecting stdout and stderr to $TMPOUT, which is defined to be "rltest.out".


		if diff output.${inp#input.} $TMPOUT > /dev/null; then
			echo "ok";

Compares a file whose name shares some pattern with the input file, except is called output.something, and checks whether there's some difference with the one created above into $TMPOUT.


If there's no difference, "ok" is echoed to the terminal.

		else
			echo "FAILED";
			rm $TMPOUT
			exit 1;

Complains if there was some difference, removes $TMPOUT, and halts with exit status 1.


		fi;
	done;
done;

-- fxn _______________________________________________ xcode-users mailing list | email@hidden Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/xcode-users Do not post admin requests to the list. They will be ignored.


References: 
 >Shell script help (From: Eric Ocean <email@hidden>)

  • Prev by Date: Re: Shell script help
  • Next by Date: Re: #include "xxx.inc" problem
  • Previous by thread: Re: Shell script help
  • Next by thread: indexing complaints (to console) about nonexistent files not found
  • Index(es):
    • Date
    • Thread