X-Git-Url: http://gitweb.hugovil.com/?a=blobdiff_plain;f=functions%2Fmain;h=720715753ca337327e367a56d8b06511b41be475;hb=564ec1bbb321286571c30da20b81620c33b18e6f;hp=e0bd99e4cf3fe0894a0b0648151e502afc8e10a4;hpb=16c81190b3ca1da2e26645020dd3cb9f8625521c;p=hvlinux.git diff --git a/functions/main b/functions/main index e0bd99e..7207157 100644 --- a/functions/main +++ b/functions/main @@ -372,20 +372,20 @@ var_export() fi # Checking if variable exists - if ! grep "${VARIABLE}=" ${FILE} 1> /dev/null 2>&1; then + if ! grep -q "${VARIABLE}=" ${FILE}; then echo "${FUNCNAME}(), variable not found: ${VARIABLE}" return 1 fi # Checking if variable is already exported when it is defined - if grep "${VARIABLE}=" ${FILE} | grep "export " 1> /dev/null 2>&1; then + if grep "${VARIABLE}=" ${FILE} | grep -q "export "; then echo "${FUNCNAME}(), variable already exported in definition: ${VARIABLE}" return 0 fi # Checking if variable is already exported, in # a "export VARIABLE1 VARIABLE2..." statement - if grep "export " ${FILE} | grep " ${VARIABLE}" 1> /dev/null 2>&1; then + if grep "export " ${FILE} | grep -q " ${VARIABLE}"; then echo "${FUNCNAME}(), variable already exported in export list: ${VARIABLE}" return 0 fi @@ -419,13 +419,13 @@ var_add() fi # Checking if variable exists - if ! grep "${VARIABLE}=" ${FILE} 1> /dev/null 2>&1; then + if ! grep -q "${VARIABLE}=" ${FILE}; then echo "${VARIABLE}=\"${VALUE}\"" >> ${FILE} return $? fi # Checking if variable contains the new value - if grep "${VARIABLE}=" ${FILE} | grep "${VALUE}" 1> /dev/null 2>&1; then + if grep "${VARIABLE}=" ${FILE} | grep -q "${VALUE}"; then echo "${FUNCNAME}(), variable ${VARIABLE} already contains value: ${VALUE}" return 0 fi @@ -434,7 +434,7 @@ var_add() # We search for the variable name starting at the beginning of the line # For example, this ensures that if the variable name is PATH, then # PATH=... matches but not MANPATH=... - if grep "^${VARIABLE}=\"" ${FILE} 1> /dev/null 2>&1; then + if grep -q "^${VARIABLE}=\"" ${FILE}; then # Variable value is enclosed by double-quotes sed -i "s!\(^${VARIABLE}=\".*\)\(\"\)!\1${SEP}${VALUE}\"!" ${FILE} else @@ -447,7 +447,7 @@ var_add() # at the beginning of a line. # For example, this ensures that if the variable name is PATH, then # PATH=... matches but not MANPATH=... - if grep "^export ${VARIABLE}=\"" ${FILE} 1> /dev/null 2>&1; then + if grep -q "^export ${VARIABLE}=\"" ${FILE}; then # Variable value is enclosed by double-quotes sed -i "s!\(^export ${VARIABLE}=\".*\)\(\"\)!\1${SEP}${VALUE}\"!" ${FILE} else @@ -500,7 +500,7 @@ string_add() fi # Checking if string exists - if grep "${STRING}" ${FILE} 1> /dev/null 2>&1; then + if grep -q "${STRING}" ${FILE}; then echo "${FUNCNAME}(), string already defined: ${STRING}" return 0 fi @@ -532,7 +532,7 @@ var_add_shadow() fi # Checking if variable contains the new value - if egrep "^${VARIABLE}" ${FILE} | grep "${VALUE}" 1> /dev/null 2>&1; then + if egrep "^${VARIABLE}" ${FILE} | grep -q "${VALUE}"; then echo "${FUNCNAME}(), variable ${VARIABLE} already contains value: ${VALUE}" return 0 fi @@ -556,7 +556,7 @@ hv_groupadd() shift done - if ! cat /etc/group | egrep "^${groupname}:" 1> /dev/null 2>&1; then + if ! cat /etc/group | egrep -q "^${groupname}:"; then groupadd ${arguments} fi } @@ -573,7 +573,7 @@ hv_useradd() shift done - if ! cat /etc/passwd | egrep "^${username}:" 1> /dev/null 2>&1; then + if ! cat /etc/passwd | egrep -q "^${username}:"; then useradd ${arguments} fi } @@ -860,8 +860,7 @@ ipkg() PACKAGE_LOG=${LFS_LOG_DIR}/${HVLABEL}.log # Checking if package was previously successfully installed - if grep "^${HVLABEL} successfully installed" ${LFS_LOG_FILE} \ - 1> /dev/null 2>&1; then + if grep -q "^${HVLABEL} successfully installed" ${LFS_LOG_FILE}; then return $EXIT_SUCCESS fi @@ -957,7 +956,7 @@ rscr() if [ "x${SCRMODE}" = "xonce" ]; then # Checking if package was previously successfully installed - if grep "^${HVLABEL} successfully installed" ${LFS_LOG_FILE} 1> /dev/null 2>&1; then + if grep -q "^${HVLABEL} successfully installed" ${LFS_LOG_FILE}; then return $EXIT_SUCCESS fi fi