What's 'side effects' of Ksh built-ins?

What's 'side effects' of Ksh built-ins?

Post by lesley Ya » Sat, 15 Jun 2002 10:49:14



Hi,

I have a book called "The new KornShell Command and Programming
Language". In several chapters, it mentions "side effects" of
built-ins. I'm confused what's that so that I can't understand some
paragraphs. Any help is appreciated.

Lesley Yang

 
 
 

What's 'side effects' of Ksh built-ins?

Post by Andreas K?h? » Sat, 15 Jun 2002 11:14:29


Submitted by "lesley Yang" to comp.unix.shell:

Quote:> Hi,

> I have a book called "The new KornShell Command and Programming
> Language". In several chapters, it mentions "side effects" of
> built-ins. I'm confused what's that so that I can't understand some
> paragraphs. Any help is appreciated.

> Lesley Yang

The cd command changes the current directory.  It changes the
value of $PWD and $OLDPWD as a side-effect.

Starting a new shell parses the file $ENV as a side-effect.

The creation of the file "/tmp/hello" is a side effect of the
following command (and so is the updating of the "last accessed"
timestamp on "/usr/bin/tee"):

    STR=$(print "hello world" | tee /tmp/hello)

Some times, the "side-effect" is the main reason for executing a
command.  The touch command, although not a ksh built-in, is
often used to update the timestamps on a file, but sometimes
it's used to create empty files.

Someone else may have a better explanation.

--
Andreas K?h?ri
--------------------------------------------------------------
Stable, secure, clean, free:  www.netbsd.org

 
 
 

1. ksh: trap '...' exit int ... or just trap '...' exit?

trap '...' exit int ...

int will cause the script to exit, so '...' get run twice:


#!/bin/ksh

trap 'print a' exit int
sleep 10

^Ca
a

But the natural exit will always causes '...' to run,
which is often not desired.

So should we always write something like

trap 'print a' exit int
...
trap - exit
exit 0
?
--
Michael Wang
http://www.unixlabplus.com/

2. scanners on solaris 10

3. ksh: 'unset' variables in 'regexp-like' fashion?

4. Changing available file handles

5. ksh ': >a >b' -vs- '>a >b' re speed

6. Problem with DHCP client and new (2.1) kernels

7. ksh children won't die ; exec doesn't work properly; ksh -p

8. ???IBM RT???

9. TK8.0 won't build, so I can't build xcdroast(0.96e)

10. Can ISP detect when dial-ins are 'overloaded' ?

11. how do 'plug-ins' work?

12. Can ISP detect when dial-ins are 'overloaded' ?

13. pd-ksh/zsh won't inherit '747=jet' env var?