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 > How to make a bourne shell user-defined function take input from heredoc
S'inscrire FAQ Membres Recherche Messages du jour Marquer les forums comme lus
comp.unix.shell Using and programming the Unix shell.

How to make a bourne shell user-defined function take input from heredoc

Réponse
 
LinkBack Outils de la discussion
Vieux 25/08/2006, 11h40   #1
Rakesh Sharma
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut How to make a bourne shell user-defined function take input from heredoc

hi,

how do we make a user-defined function in bourne shells to be able to
take it's input(s) from either it's argument list or a heredoc?

For example,

func1() {
printf '%s\n' "$@"
return 0
}

func1 "$var1" 'arg2' # works fine when arguments provided
# by means of shell variables or hardcoded strings

# but this doesnt work
func1 << EOF
this is some heredoc
usage: FOOBAR tmpdir tmpfile codename
EOF

Regards,
Rakesh

  Réponse avec citation
Vieux 25/08/2006, 12h30   #2
Stephane Chazelas
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: How to make a bourne shell user-defined function take input from heredoc

On 25 Aug 2006 03:40:49 -0700, Rakesh Sharma wrote:
> hi,
>
> how do we make a user-defined function in bourne shells to be able to
> take it's input(s) from either it's argument list or a heredoc?
>
> For example,
>
> func1() {
> printf '%s\n' "$@"
> return 0
> }
>
> func1 "$var1" 'arg2' # works fine when arguments provided
> # by means of shell variables or hardcoded strings
>
> # but this doesnt work
> func1 << EOF
> this is some heredoc
> usage: FOOBAR tmpdir tmpfile codename
> EOF

[...]

func1() {
if [ "$#" -eq 0 ]; then
cat
else
printf '%s\n' "$@"
fi
return 0
}

--
Stephane
  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 17h49.


É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,08220 seconds with 10 queries