<?xml version="1.0" encoding="UTF-8" ?>

<bugzilla version="5.2"
          urlbase="https://bugzilla.altlinux.org/"
          
          maintainer="jenya@basealt.ru"
>

    <bug>
          <bug_id>18458</bug_id>
          
          <creation_ts>2009-01-08 19:42:51 +0300</creation_ts>
          <short_desc>Громоздкая проверка существования пользователя в группе</short_desc>
          <delta_ts>2009-05-10 09:34:00 +0400</delta_ts>
          <reporter_accessible>1</reporter_accessible>
          <cclist_accessible>1</cclist_accessible>
          <classification_id>4</classification_id>
          <classification>Development</classification>
          <product>Sisyphus</product>
          <component>mknfsroot</component>
          <version>unstable</version>
          <rep_platform>all</rep_platform>
          <op_sys>Linux</op_sys>
          <bug_status>CLOSED</bug_status>
          <resolution>NOTABUG</resolution>
          
          
          <bug_file_loc></bug_file_loc>
          <status_whiteboard></status_whiteboard>
          <keywords></keywords>
          <priority>P2</priority>
          <bug_severity>minor</bug_severity>
          <target_milestone>---</target_milestone>
          
          
          <everconfirmed>1</everconfirmed>
          <reporter name="Eugene Ostapets">eostapets</reporter>
          <assigned_to name="Nobody&apos;s working on this, feel free to take it">nobody</assigned_to>
          <cc>ldv</cc>
    
    <cc>mike</cc>
    
    <cc>php-coder</cc>
          
          <qa_contact>qa-sisyphus</qa_contact>

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>83972</commentid>
    <comment_count>0</comment_count>
    <who name="Eugene Ostapets">eostapets</who>
    <bug_when>2009-01-08 19:42:51 +0300</bug_when>
    <thetext>Для проверки существования пользователя можно воспользоваться конструкцией

if ! groups _mknfsroot | grep -q hashman ; then
...
fi</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>84027</commentid>
    <comment_count>1</comment_count>
    <who name="Dmitry V. Levin">ldv</who>
    <bug_when>2009-01-09 03:55:10 +0300</bug_when>
    <thetext>(In reply to comment #0)
&gt; Для проверки существования пользователя можно воспользоваться
&gt; конструкцией
&gt; 
&gt; if ! groups _mknfsroot | grep -q hashman ; then

(не видя оригинал)
Простого grep -q недостаточно, нужен именно -x:
if ! groups _mknfsroot |cut -d: -f2- |tr &apos;[:space:]&apos; &apos;\n&apos; |fgrep -qx hashman; then
</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>84040</commentid>
    <comment_count>2</comment_count>
    <who name="Eugene Ostapets">eostapets</who>
    <bug_when>2009-01-09 14:23:14 +0300</bug_when>
    <thetext>Хм... А какую потенциальную проблему обходит эта громоздкость и почему нельзя обойтись fgrep -wq?(Это так, для саморазвития) </thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>84043</commentid>
    <comment_count>3</comment_count>
    <who name="Dmitry V. Levin">ldv</who>
    <bug_when>2009-01-09 17:28:36 +0300</bug_when>
    <thetext>(In reply to comment #2)
&gt; Хм... А какую потенциальную проблему обходит эта громоздкость и почему
&gt; нельзя обойтись fgrep -wq?(Это так, для саморазвития)

1. в вашем варианте не было -w

2. -w недостаточно:
$ echo foo-hashman |fgrep -wc hashman
1
$ echo foo-hashman |fgrep -xc hashman
0
</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>84048</commentid>
    <comment_count>4</comment_count>
    <who name="Eugene Ostapets">eostapets</who>
    <bug_when>2009-01-09 17:52:20 +0300</bug_when>
    <thetext>Хм... Согласен, ступил...</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>84058</commentid>
    <comment_count>5</comment_count>
    <who name="Slava Semushin">php-coder</who>
    <bug_when>2009-01-09 21:57:19 +0300</bug_when>
    <thetext>(In reply to comment #0)
&gt; Для проверки существования пользователя можно воспользоваться
&gt; конструкцией

if getent group _mknfsroot &gt;/dev/null; then
    ...
fi
</thetext>
  </long_desc>
      
      

    </bug>

</bugzilla>