Nirbheek Chauhan wrote:
> On Fri, Sep 26, 2008 at 2:09 PM, Steve Long <slong@...>
> wrote:
>> Nirbheek Chauhan wrote:
>>> $(for ACRONYM in ${LinkedIn}; do echo -en "${ACRONYM},"; done; echo -ne
>>> '\b')
>>>
>> Now that *is* fail ;-)
>
> Crap! I forgot, \b only works for displaying in the terminal; doesn't
> actually "backspace" :(
>
Eh works well enough for display (not file as you mentioned) it's just you
should know about "${arr[*]}" vs "${arr[@]}"
Both are designed to help with scriptin; the first with exactly this issue,
and the latter with handling array parameters correctly, analagous to "$@"
and "$*".
Check out http://wooledge.org:8000/BashFAQ/073 for more nice stuff you can
do with array expansions (as well as scalars.)
>>
>>> So, where's my free review? ;p
>>>
>> isArr LinkedIn || LinkedIn=($LinkedIn)
>> oIFS=$IFS
>> IFS=, # This line and next are what you should
>> echo "${LinkedIn[*]}" # be aware of. cf: /msg greybot $@
>> IFS=$oIFS
>>
>> (We just do: declare -r oIFS=$IFS
>> ..at the start of our scripts, as it makes life easier in the long-run.)
>
> Sigh... I think it's better to just live with the extra comma :p
>
Pfft, you were already using an array: $(IFS=,; echo "${LinkedIn[*]}")
would've done. Since there was a subshell there, no need to worry about
saving IFS. Reason I mentioned it is because: unset IFS
isn't the same, and is generally useless compared to IFS=$oIFS ime.
(The isArr line just seemed better than '# if this is not an array..')
|