PHWinfo banniere

Titres
PORTAIL ANNUAIRE ARTICLES COMPARATEUR HÉBERGEURS DEVIS FORUMS RÉDUCTEUR D'URL
Précédent   PHWinfo > Forums Hébergement > Forum Serveur - Sécurité et techniques > comp.unix.shell > IRIX - ksh use of set -x
S'inscrire FAQ Membres Recherche Messages du jour Marquer les forums comme lus
comp.unix.shell Using and programming the Unix shell.

IRIX - ksh use of set -x

Réponse
 
LinkBack Outils de la discussion
Vieux 03/11/2007, 21h05   #1
John Horne
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut IRIX - ksh use of set -x

Hello,

I am trying to resolve a problem in a script which is being used by an
IRIX 6.5 user. I gather that by default the IRIX root account uses tcsh,
but the script starts with '#! /bin/sh', and 'sh' is the Korn shell.

The problem is that the script uses 'set -x' for tracing at one point.
This works fine in the main script, but it seems that the tracing does
not carry through to functions coded in the script. Simple example:

today_is() {
date
return
}

set -x
echo Starting...
today_is
echo ending.

The 'set -x' will cause the 'echo' statements and the 'today_is' function
name to be echoed, but the 'date' command in the function is not. I don't
want to have to use 'set -x' in every function because the script is
large and has many defined functions.

This use of 'set -x' works fine under Linux, Solaris (using ksh), AIX,
and *BSD. IRIX is the only O/S that has caused a problem.

Anyone, know how I can get IRIX to use tracing within functions without
having to 'set -x' in each of them?



Thanks,

John.
  Réponse avec citation
Vieux 04/11/2007, 09h23   #2
Stephane CHAZELAS
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: IRIX - ksh use of set -x

2007-11-03, 20:05(+00), John Horne:
[...]
> I am trying to resolve a problem in a script which is being used by an
> IRIX 6.5 user. I gather that by default the IRIX root account uses tcsh,
> but the script starts with '#! /bin/sh', and 'sh' is the Korn shell.
>
> The problem is that the script uses 'set -x' for tracing at one point.
> This works fine in the main script, but it seems that the tracing does
> not carry through to functions coded in the script. Simple example:
>
> today_is() {
> date
> return
> }
>
> set -x
> echo Starting...
> today_is
> echo ending.
>
> The 'set -x' will cause the 'echo' statements and the 'today_is' function
> name to be echoed, but the 'date' command in the function is not. I don't
> want to have to use 'set -x' in every function because the script is
> large and has many defined functions.
>
> This use of 'set -x' works fine under Linux, Solaris (using ksh), AIX,
> and *BSD. IRIX is the only O/S that has caused a problem.
>
> Anyone, know how I can get IRIX to use tracing within functions without
> having to 'set -x' in each of them?

[...]

Yes, that's a known annoying /feature/ of ksh88.

You can add a:

eval "typeset -ft $(typeset +f)"

after your function declarations.


--
Stéphane
  Réponse avec citation
Vieux 04/11/2007, 13h46   #3
Sven Mascheck
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: IRIX - ksh use of set -x

John Horne wrote:

> 'set -x' works fine under Linux, Solaris (using ksh), [...]


Solaris: have you confused the ksh with the Bourne shell?
  Réponse avec citation
Vieux 04/11/2007, 19h42   #4
John Horne
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: IRIX - ksh use of set -x

On Sun, 04 Nov 2007 14:46:57 +0100, Sven Mascheck wrote:

> John Horne wrote:
>
>> 'set -x' works fine under Linux, Solaris (using ksh), [...]

>
> Solaris: have you confused the ksh with the Bourne shell?
>

No, the original script detects it's not running ksh and so execs to it.
By the time the 'set -x' is reached, ksh is the interpreter being used.

However, re-testing this does indeed show that the use of 'set -x' alone
does not work under Solaris 10 ksh.


John.
  Réponse avec citation
Vieux 04/11/2007, 19h46   #5
John Horne
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: IRIX - ksh use of set -x

On Sun, 04 Nov 2007 09:23:41 +0000, Stephane CHAZELAS wrote:

> 2007-11-03, 20:05(+00), John Horne:
> [...]


>>
>> Anyone, know how I can get IRIX to use tracing within functions without
>> having to 'set -x' in each of them?

> [...]
>
> Yes, that's a known annoying /feature/ of ksh88.
>
> You can add a:
>
> eval "typeset -ft $(typeset +f)"
>
> after your function declarations.
>

Many thanks for this, and it seems to work fine except for one point. The
'typeset +f' returns multiple function names one-per-line, causing the
'typeset -ft' not to work correctly. I resolved this simply by using an
'echo' to cause the newlines to become spaces. It then all works fine,
and tracing occurs in the functions.

Tested on Solaris 10, I'll get back to the IRIX user to see what happens.


Many thanks,

John.

  Réponse avec citation
Vieux 04/11/2007, 19h51   #6
Stephane CHAZELAS
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: IRIX - ksh use of set -x

2007-11-04, 19:46(+00), John Horne:
> On Sun, 04 Nov 2007 09:23:41 +0000, Stephane CHAZELAS wrote:
>
>> 2007-11-03, 20:05(+00), John Horne:
>> [...]

>
>>>
>>> Anyone, know how I can get IRIX to use tracing within functions without
>>> having to 'set -x' in each of them?

>> [...]
>>
>> Yes, that's a known annoying /feature/ of ksh88.
>>
>> You can add a:
>>
>> eval "typeset -ft $(typeset +f)"
>>
>> after your function declarations.
>>

> Many thanks for this, and it seems to work fine except for one point. The
> 'typeset +f' returns multiple function names one-per-line, causing the
> 'typeset -ft' not to work correctly. I resolved this simply by using an
> 'echo' to cause the newlines to become spaces. It then all works fine,
> and tracing occurs in the functions.
>
> Tested on Solaris 10, I'll get back to the IRIX user to see what happens.

[...]

Oh yes sorry,

typeset -ft $(typeset +f)

will do then as long as you don't modify $IFS.

Or

eval "typeset -ft $(typeset +f | paste -s -)"

--
Stéphane
  Réponse avec citation
Réponse


Outils de la discussion

Règles de messages
Vous ne pouvez pas créer de nouvelles discussions
Vous ne pouvez pas envoyer des réponses
Vous ne pouvez pas envoyer des pièces jointes
Vous ne pouvez pas modifier vos messages

Les balises BB sont activées : oui
Les smileys sont activés : oui
La balise [IMG] est activée : oui
Le code HTML peut être employé : non
Trackbacks are oui
Pingbacks are oui
Refbacks are oui


Fuseau horaire GMT +1. Il est actuellement 20h56.


Édité par : vBulletin® version 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.2.0 RC5 Tous droits réservés.
Version française #16 par l'association vBulletin francophone
PHWinfo est un site Éducation Sans Frontières ©2000-2008
Ad Management by RedTyger
©Tous droits réservés par les parties respectives
Page generated in 0,14577 seconds with 14 queries