[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Help-bash] play audio-CD in consol
From: |
Gerard ROBIN |
Subject: |
Re: [Help-bash] play audio-CD in consol |
Date: |
Wed, 30 Jan 2013 18:42:01 +0100 |
User-agent: |
Mutt/1.5.21 (2010-09-15) |
On Wed, Jan 30, 2013 at 06:54:14AM +1100, Matthew Cengia wrote:
> Date: Wed, 30 Jan 2013 06:54:14 +1100
> From: Matthew Cengia <address@hidden>
> To: Mart Frauenlob <address@hidden>
> Cc: address@hidden, address@hidden
> Subject: Re: [Help-bash] play audio-CD in consol
> User-Agent: Mutt/1.5.20 (2009-06-14)
>
> Please see comment below.
> On 2013-01-29 14:52, Mart Frauenlob wrote:
> [...]
> > >
> > >echo -e "\n"$center$frame"\n" $center$title"\n"$center$frame
> > >
> > >echo -e "\n\tListen to audio CDs with alsaplayer
> > >(http://www.alsaplayer.org/)"
> > >echo -e "\n\tFirst of all you must edit the ~/.alsaplayer/config
> > >\tComplement or add the following lines:
> > >\n\t 1 cdda.cddb_servername=freedb.freedb.org
> > >\t 2 cdda.cddb_serverport=8880
> > >\t 3 cdda.device=/dev/sr0 # replace /dev/sr0 by the good path of your box.
> > >\t 4 cdda.do_cddb_lookup=true"
> > >
> > >echo -e "\n\t\tTo play a CD, type: play, then Enter
> > >\t\tTo exit alsaplayer, keep playing, type exit and Enter
> > >\t\tTo stop the CD, if it is playing, type stop and Enter
> > >\t\tEnter ? for more help"
> > >
> >
> > hard to read, I'd prefer printf, or here-document redirection here.
> >
>
> Regarding the above, I would go so far as to almost *mandate* printf. I
> realise this is a Bash mailing list, but, as part of good coding
> practice (mostly in case you find your script running in a non-bash
> shell:
>
> 06:51 <mattcen> !echo
> 06:51 <greybot> echo outputs a string. echo has many portability problems, and
> should never be used with option flags. In POSIX shells, use:
> `printf '%b\n' "args"' or `printf %s "args"' for -e and -n
> respectively. For ksh-like shells other than Bash: print
> -[r|n].
> http://wiki.bash-hackers.org/commands/builtin/echo |
> http://cfajohnson.com/shell/cus-faq.html#Q0b |
> http://www.in-ulm.de/~mascheck/various/echo+printf
I would like to know if to display the 3 following lines:
foo bar base
foo bar base foo bar baz
foo bar base foo bar baz foo bar base
it is the appropriate way to write:
line1="foo bar base"
line2="foo bar base foo bar baz"
line3="foo bar base foo bar baz foo bar base"
printf "%$((${#line1}+10))s\n%$((${#line2}+10))s\n%$((${#line3}+10))s\n"
"$line1" "$line2" "$line3"
If yes, printf is hard to read (and write) too. If not, how can we write
this most simply ? ( with printf )
Here-document is very friendly if we only use the bash. :)
Thanks
--
GĂ©rard