Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: Read-only variables in emulation mode



On Dec 16,  8:10pm, Oystein Walle wrote:
} Subject: Read-only variables in emulation mode
}
} I assume status and _ are meant to be writable in POSIX shells.

Hmm.  According to the doc, "status" should be writable but "_" not.

    status <S> <Z>

    _ <S>

(The <S> means "special", the <Z> means "but only in native zsh mode".)

} A common idiom in (ba)sh scripting is to use _ as a throwaway in a
} while-read loop:
} 
}     while read -r col1 _ col2; do
}         echo "col1 = $col1 and col2 = $col2"
}     done < three-columns.txt

Well, that's one I'd never seen before.  Certainly that's about the only
place it's "safe" to use "_" because it's always immediately going to be
clobbered.
 
} In the mean time, is there any way around it?

Only by using a function scope and declaring "local -h _ status" to hide
the special variables.



Messages sorted by: Reverse Date, Date, Thread, Author