autoconf
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Redirecting to a stream number held in a variable


From: MarkHobley
Subject: Redirecting to a stream number held in a variable
Date: Tue, 29 Dec 2009 14:10:46 -0800 (PST)

I have a function that is being generated by autoconf as follows:

as_fn_error ()
{
    ...
    $as_echo "$as_me:${as_lineno-$LINENUM}: error: $1" >&$3
    ...
}

This basically expands to give:

echo "foobar" >&$3

The echo command with the redirection causes a syntax error on some shells,
although often the function is skipped over, so the error goes unnoticed.

> Which shells, and what is the text of the error?
echo "foobar" >&$3

ash:
Syntax error: Bad fd number

hsh: (I think this one works)
foobar

dash:
dash: Syntax error: Bad fd number

ksh:  (pkdsh)
ksh: >& : illegal file descriptor name

posh:
posh: >& : illegal file descriptor name

bash:
bash: $3: ambiguous redirect

I haven't narrowed this down to a specific fault, but I suspect an error in
the m4sh code. I think 
Has anyone else seen this?

I think this comes from _AS_ERROR_PREPARE:

    [Output "`basename @S|@0`: error: ERROR" to stderr.]
m4_ifval(AS_MESSAGE_LOG_FD,
    [[If LINENO and LOG_FD are provided, also output the error to LOG_FD,
      referencing LINENO.]])
    [Then exit the script with status $?, using 1 if that was 0.])],
[  as_status=$?; test $as_status -eq 0 && as_status=1
m4_ifval(AS_MESSAGE_LOG_FD,
[m4_pushdef([AS_MESSAGE_LOG_FD], [$[3]])dnl
  if test "$[3]"; then
    AS_LINENO_PUSH([$[2]])
    _AS_ECHO_LOG([error: $[1]])
  fi
m4_define([AS_MESSAGE_LOG_FD])], [m4_pushdef([AS_MESSAGE_LOG_FD])])dnl
  AS_MESSAGE([error: $[1]], [2])
_m4_popdef([AS_MESSAGE_LOG_FD])dnl
  AS_EXIT([$as_status])])])

I could do with a modification here so that I don't get an >&$ redirection
structure. Can anyone advise on how to fix this within m4sh?

Mark.


-- 
View this message in context: 
http://old.nabble.com/Redirecting-to-a-stream-number-held-in-a-variable-tp26961196p26961196.html
Sent from the Gnu - Autoconf - General mailing list archive at Nabble.com.





reply via email to

[Prev in Thread] Current Thread [Next in Thread]