On 27 February 2013 10:58, Binand Sethumadhavan <[email protected]> wrote:
> On 27 February 2013 10:52, Rajeev R. K. <[email protected]> wrote:
>>> How about:
>>>
>>> if [ $( grep -cE '/(home|backup)' /etc/mtab ) = 2 ]; then
>>>     echo Found both mounts
>>> else
>>>     echo Found only one of the two mounts
>>> fi
>>>
>>> (Refine as per your needs)
>>>
>>
>> Fails for Case where mount points /home and /home_new exist. Still get
>> count 2 with no backup. In addition, if i have /backup mounted too,
>
> Come on man, that's why I specifically mentioned "refine to your
> needs". If I were to refine this for Rony's needs as he articulated,
> I'd write that regex as:
>
> '^[^[:space:]]*[[:space:]]/(home|backup)[[:space:]]'
>
> Which covers all the special cases you mention and some more.

Lolz, No worries man, i was just approaching it from a design
perspective, rather than targeting code brevity. I still say having
independent tests makes most of these edge cases moot, and plus has
another important advantage from a usability perspective. It allows
you to specifically inform the user of why the script aborted,
specifically identifying which of the 2 required mount points was not
available(or both, for that matter). If the script is to fail, let it
fail with class :-)

Regards
R. K. Rajeev

>
> Binand
> --
> http://mm.ilug-bom.org.in/mailman/listinfo/linuxers
-- 
http://mm.ilug-bom.org.in/mailman/listinfo/linuxers

Reply via email to