Code Comments
Programming Forum and web based access to our favorite programming groups.How can I port same shell script in to different shells like C Shell, K Shell and Bourne Shell Chitta
Post Follow-up to this messagec_jena@ureach.com writes:
> How can I port same shell script in to different shells like C Shell, K
> Shell and Bourne Shell
Launching your favorite editor, reading the man page of the source and
the target shell, thinking, and editing the script file.
Also, it's possible to write a single source file usable both in csh,
sh, Fortran and C, and perhaps it would be possible to add more
languages, so you would not need to "port" the script...
happy.source:
------------------------------------------------------------------------
cat /*dev/null; echo "Happy New Year"\!
cat <<c*/ /*dev/null | cat > /dev/null
c */ () {} /*
c */ main() { cat(); printf("Happy New Year!\n"); } /*
17 format('Happy New Year!')
write (6,17)
stop
end
c*/
------------------------------------------------------------------------
Makefile:
------------------------------------------------------------------------
all: happy-c happy-f happy-sh happy-csh
happy-c:happy.source Makefile
@ cp happy.source happy-c.c
@ gcc -o happy-c happy-c.c
@ echo -n '(C) '
@ ./happy-c || true
happy-f:happy.source Makefile
@ cp happy.source happy-f.f
@ f77 -o happy-f happy-f.f 2> /dev/null
@ echo -n '(FORTRAN) '
@ ./happy-f
happy-sh:happy.source Makefile
@ cp happy.source happy-sh
@ echo -n '(Bourne Shell) '
@ chmod 755 happy-sh
@ sh ./happy-sh
happy-csh:happy.source Makefile
@ cp happy.source happy-csh
@ chmod 755 happy-csh
@ echo -n '(C Shell) '
@ csh ./happy-csh
clean:
-rm -f *.o *~ happy-csh happy-sh happy-f happy-f.f happy-c happy-c.c
------------------------------------------------------------------------
--
__Pascal Bourguignon__ http://www.informatimago.com/
In a World without Walls and Fences,
who needs Windows and Gates?
Post Follow-up to this message* Pascal Bourguignon <spam@mouse-potato.com> | happy.source: kEWl, D00dE. R'
Post Follow-up to this messagec_jena@ureach.com wrote: > How can I port same shell script in to different shells like C Shell, K > Shell and Bourne Shell Since the KornShell was designed to be a compatible replacement of the Bourne Shell, it's easy to write a script that runs with both shells. Just limit yourself to the Bourne Shell constructs, which are understood by both shells. The C-Shell is something completely different, inventing a completely independent command language. The Bourne Shell and C-Shell command sets are disjoint by a large degree. The following script shows, that it still is possible to use all together in one script: http://www.shelldorado.com/scripts/cmds/shtype Heiner -- ___ _ / __| |_ _____ _____ _ _ Heiner STEVEN <heiner.steven@nexgo.de> \__ \ _/ -_) V / -_) ' \ Shell Script Programmers: visit |___/\__\___|\_/\___|_||_| http://www.shelldorado.com/
Post Follow-up to this message
Show a Printable Version
Email This Page to Someone!
Receive updates to this thread
Powered by vBulletin
Copyright 2000-2006 Jelsoft Enterprises Limited.