On Thu, Apr 21, 2016 at 10:00:08PM -0700, David Champion wrote: > * On 21 Apr 2016, Xu Wang wrote: > > Hi, > > > > I would like to have a print command that takes input from the user. > > But mutt pipes the message to the print command so I guess I cannot > > use something like > > read -p "where to save?" filename > > > > because read looks on STDIN and mutt already piped to STDIN. > > You've analyzed it right. Solution: read </dev/tty > > #!/bin/bash > ## WARNING UNCHECKED INPUT > ## JUST A PROOF OF CONCEPT > read -p 'Save to: ' fn </dev/tty > cat >"$fn"
Unless it has changed recently, bash runs redirected read commands in a sub-process. Thus the variable fn would not get set in the main process. jl -- Jon H. LaBadie j...@jgcomp.com 11226 South Shore Rd. (703) 787-0688 (H) Reston, VA 20190 (703) 935-6720 (C)