Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Grep #81

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open

Grep #81

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 8 additions & 14 deletions libs/aliases.lunar
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,12 @@ unalias() {
return
fi

# shortcut out when explicitly instructed so
if [[ -n "$NEVER_ASK" ]] ; then
echo $1
return
fi

debug_msg "unalias($@)"
# try to figure out where the aliases file is:
if [[ -z "$ALIASES" ]] || [[ ! -f "$ALIASES" ]]; then
Expand All @@ -38,12 +44,6 @@ unalias() {

TARGETS=$(awk -F: -v mod=$1 '{if ($1==mod){print $2}}' "$ALIASES")

# shortcut out when explicitly instructed so
if [[ -n "$NEVER_ASK" ]] ; then
echo $1
return
fi

# propose one and let the user pick it from a list:
debug_msg "unalias: starting selection loop"
error_message "${MODULE_COLOR}$MODULE${DEFAULT_COLOR}${MESSAGE_COLOR} depends on ${DEFAULT_COLOR}${QUERY_COLOR}\"${1:1}\"${DEFAULT_COLOR}${MESSAGE_COLOR} which is an alias${DEFAULT_COLOR}"
Expand All @@ -62,14 +62,8 @@ unalias() {
done
echo -n -e "${MESSAGE_COLOR}Choice> ${DEFAULT_COLOR}" >&2
read -t $PROMPT_DELAY CHOICE
# test directly first
if echo $TARGETS | grep -qw "$CHOICE" ; then
verbose_msg "Stored alias mapping $1 -> $TARGET"
set_local_config `echo LUNAR_ALIAS_${1:1}` $TARGET
echo $TARGET
return
# then the number, resolving the default
elif [[ -n "${TARGETBYNUM[${CHOICE:=1}]}" ]] ; then
# test the number, resolving the default
if [[ -n "${TARGETBYNUM[${CHOICE:=1}]}" ]] ; then
verbose_msg "Stored alias mapping $1 -> ${TARGETBYNUM[$CHOICE]}"
set_local_config `echo LUNAR_ALIAS_${1:1}` ${TARGETBYNUM[$CHOICE]}
echo ${TARGETBYNUM[$CHOICE]}
Expand Down
8 changes: 4 additions & 4 deletions libs/build.lunar
Original file line number Diff line number Diff line change
Expand Up @@ -44,12 +44,12 @@ save_libraries() {
SAVED=$OLD_LIBS/$MODULE.saved.libraries
rm -rf $SAVED

grep "/lib/" "$OLD_LOG" |
fgrep '/lib/' "$OLD_LOG" |
while read LINE; do

if [ -f "$LINE" ] &&
file -bL $LINE |
grep -q "shared object"
fgrep -wq 'shared object'
then
verbose_msg "saving library \"$LINE\""
if [ -h $LINE ]; then
Expand Down Expand Up @@ -96,7 +96,7 @@ export_ld() {
local DIRECTORY
debug_msg "export_ld ($@)"
for DIRECTORY in $* ; do
if file -b $DIRECTORY/*.so* | grep -q "shared object" ; then
if file -b $DIRECTORY/*.so* | fgrep -wq 'shared object' ; then
if [ -z "$LD_LIBRARY_PATH" ] ; then
export LD_LIBRARY_PATH="$DIRECTORY"
else
Expand Down Expand Up @@ -346,7 +346,7 @@ run_configure() {
fi

prepare_module_config
grep -q "^"$MODULE"\$" "$TEMP_PREPAREDDEPS" 2>/dev/null && return 0
fgrep -xq "$MODULE" "$TEMP_PREPAREDDEPS" 2>/dev/null && return 0

# add custom passed OPTS before retrieving them
if [ -n "$PASS_OPTS" ] ; then
Expand Down
2 changes: 1 addition & 1 deletion libs/check.lunar
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ rework_module() {
(
if run_details $1 &> /dev/null ; then
if has_module_file $MODULE DEPENDS ; then
run_module_file $MODULE DEPENDS | grep -v '%'
run_module_file $MODULE DEPENDS | fgrep -v '%'
fi
fi
)
Expand Down
4 changes: 2 additions & 2 deletions libs/config.lunar
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ set_config()
VAR=${2#"${2%%[![:space:]]*}"}
VAR=${VAR%%+([[:space:]])}

LINE=$(grep -w "$VAR=.*" "$1")
LINE=$(grep "\<$VAR=.*" "$1")
FILE=$1

shift 2
Expand Down Expand Up @@ -72,7 +72,7 @@ unset_config()
get_config()
{
if [[ -f $1 ]] ; then
grep -w "$2=.*" "$1" | cut -d= -f2- | sed -e 's/^"//' -e 's/"$//'
grep "\<$2=.*" "$1" | cut -d= -f2- | sed -e 's/^"//' -e 's/"$//'
fi
}

Expand Down
30 changes: 15 additions & 15 deletions libs/depends.lunar
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ function find_depends() {
for DEP in $DEPS ; do
DEP=$(unalias "$DEP")
# this is our shortcut out:
if ! grep -qx "$DEP" "$TMP_FDEPS" ; then
if ! fgrep -qx "$DEP" "$TMP_FDEPS" ; then
echo "$DEP" >> $TMP_FDEPS
if grep -q "^$1:$DEP:required:" "$DEPENDS_CACHE" ; then
echo "$DEP"
Expand Down Expand Up @@ -105,13 +105,13 @@ sort_by_dependency() {
# note that this is logically WRONG, but it actually will help with
# unincluded depends, and therefore is *better* behaviour
for M in $* ; do
if ! grep -q -x "$M" "$TMP_ALL" ; then
if ! fgrep -q -x "$M" "$TMP_ALL" ; then
echo $M >> $TMP_ALL
fi
done

# now reverse grep over the files:
cat "$TMP_ALL" | grep -x -f "$TMP_LIST"
cat "$TMP_ALL" | fgrep -x -f "$TMP_LIST"

temp_destroy $TMP_LIST
temp_destroy $TMP_ALL
Expand All @@ -121,7 +121,7 @@ sort_by_dependency() {
is_depends() {
debug_msg "is_depends ($@)"
# Is $1 a previously selected dependency of any module.
return $(grep -q ":$1:on:" "$DEPENDS_STATUS")
return $(fgrep -q ":$1:on:" "$DEPENDS_STATUS")
}


Expand All @@ -148,7 +148,7 @@ remove_depends() {
fi
elif grep -q "^$1:" "$DEPENDS_STATUS" ; then
grep -v "^$1:" "$DEPENDS_STATUS_BACKUP" | \
grep -v ":$1:on:optional:" > $DEPENDS_STATUS
fgrep -v ":$1:on:optional:" > $DEPENDS_STATUS
verbose_msg "removing all depends for and optional on \"$1\""
fi

Expand All @@ -161,7 +161,7 @@ remove_depends() {

add_depends() {
debug_msg "add_depends ($@)"
if ! grep -q "^$1:$2:$3:$4:$5:$6$" "$DEPENDS_STATUS" ; then
if ! fgrep -xq "$1:$2:$3:$4:$5:$6" "$DEPENDS_STATUS" ; then
lock_file $DEPENDS_STATUS_BACKUP &&
lock_file $DEPENDS_STATUS &&
if grep -q "^$1:$2:" "$DEPENDS_STATUS" ; then
Expand Down Expand Up @@ -198,7 +198,7 @@ run_depends() {
"${MODULE_COLOR}$DEP${DEFAULT_COLOR}"
fi
# don't check depends if there are already checked
if grep -q "^$DEP\$" "$TEMP_PREPAREDDEPS" 2>/dev/null ; then
if fgrep -xq "$DEP" "$TEMP_PREPAREDDEPS" 2>/dev/null ; then
return 0
fi
lin --deps $DEP
Expand All @@ -219,7 +219,7 @@ run_depends() {
if in_depends $MODULE $DEP ; then
if ! module_installed $DEP ; then
# don't check depends if there are already checked
if grep -q "^$DEP\$" "$TEMP_PREPAREDDEPS" 2>/dev/null ; then
if fgrep -xq "$DEP" "$TEMP_PREPAREDDEPS" 2>/dev/null ; then
return 0
fi
lin --deps $DEP
Expand All @@ -244,7 +244,7 @@ run_depends() {
verbose_msg "Enforcing optional dependency \"$DEP\""
add_depends "$MODULE" "$DEP" "on" "optional" "$2" "$3"
# don't check depends if there are already checked
if grep -q "^$DEP\$" "$TEMP_PREPAREDDEPS" 2>/dev/null ; then
if fgrep -xq "$DEP" "$TEMP_PREPAREDDEPS" 2>/dev/null ; then
return 0
fi
lin --deps $DEP
Expand All @@ -253,7 +253,7 @@ run_depends() {
verbose_msg "Auto-adding optional dependency \"$DEP\""
add_depends "$MODULE" "$DEP" "on" "optional" "$2" "$3"
# don't check depends if there are already checked
if grep -q "^$DEP\$" "$TEMP_PREPAREDDEPS" 2>/dev/null ; then
if fgrep -xq "$DEP" "$TEMP_PREPAREDDEPS" 2>/dev/null ; then
return 0
fi
lin --deps $DEP
Expand All @@ -262,7 +262,7 @@ run_depends() {
${QUERY_COLOR}Purpose: ${DEFAULT_COLOR}${MESSAGE_COLOR}$4 ${QUERY_COLOR}?" $DEFAULT ; then
add_depends "$MODULE" "$DEP" "on" "optional" "$2" "$3"
# don't check depends if there are already checked
if grep -q "^$DEP\$" "$TEMP_PREPAREDDEPS" 2>/dev/null ; then
if fgrep -xq "$DEP" "$TEMP_PREPAREDDEPS" 2>/dev/null ; then
return 0
fi
lin --deps $DEP
Expand All @@ -274,7 +274,7 @@ run_depends() {
fi
}

grep -q "^"$MODULE"\$" "$TEMP_PREPAREDDEPS" 2>/dev/null && return 0
fgrep -xq "$MODULE" "$TEMP_PREPAREDDEPS" 2>/dev/null && return 0
if has_module_file $MODULE DEPENDS ; then
if [ -n "$SINGLE_MODULE" ] ; then
# we only need to show this once, but we get here twice per module
Expand Down Expand Up @@ -310,7 +310,7 @@ satisfy_depends() {
grep "^$MODULE:" "$DEPENDS_STATUS" > $TMP_FILE

# first recursively check if all required dependencies are installed
for DEP_MODULE in $(find_depends $MODULE | grep -v '%') ; do
for DEP_MODULE in $(find_depends $MODULE | fgrep -v '%') ; do
if [ $DEP_MODULE != $MODULE ]; then
if ! module_installed $DEP_MODULE ; then
if module_exiled $DEP_MODULE ; then
Expand Down Expand Up @@ -445,7 +445,7 @@ create_depends_cache()

# speedups for system moonbases:
if [ "$MOONBASE" == "/var/lib/lunar/moonbase" ] && [ -f "$INSTALL_LOGS/moonbase-$(installed_version moonbase)" ] ; then
DEPFILES=$(grep "/DEPENDS$" "$INSTALL_LOGS/moonbase-$(installed_version moonbase)")
DEPFILES=$(grep '/DEPENDS$' "$INSTALL_LOGS/moonbase-$(installed_version moonbase)")
# don't forget zlocal:
if [ "$ZLOCAL_OVERRIDES" == "on" ] ; then
DEPFILES="$DEPFILES $(find $MOONBASE/zlocal -type f -name DEPENDS)"
Expand Down Expand Up @@ -543,7 +543,7 @@ update_depends()
list_installed_depending() {
local SUBDEP
debug_msg "list_installed_depending($2)"
for SUBDEP in $(grep ":$1:" "$DEPENDS_CACHE" | cut -d: -f1) ; do
for SUBDEP in $(fgrep ":$1:" "$DEPENDS_CACHE" | cut -d: -f1) ; do
if $(module_installed $SUBDEP ) ; then
list_installed_depending $SUBDEP | sort | uniq
echo $SUBDEP
Expand Down
20 changes: 10 additions & 10 deletions libs/download.lunar
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ lget_lock() {
lget_locked() {
debug_msg "lget_locked ($@)"
if [ -f "/var/lock/lgetting.$MODULE" ] &&
ps `cat "/var/lock/lgetting.$MODULE"` | grep -q "lget" ; then
ps `cat "/var/lock/lgetting.$MODULE"` | fgrep -wq 'lget' ; then
true
else
false
Expand Down Expand Up @@ -84,7 +84,7 @@ download_module() {

add_url() {
if [ -n "$1" ]; then
if ! echo " $ALL_URLS " | grep -q " $1 "; then
if ! echo " $ALL_URLS " | fgrep -q " $1 "; then
ALL_URLS="$ALL_URLS $1"
fi
fi
Expand Down Expand Up @@ -119,7 +119,7 @@ download_module() {

# scan for hits against known clusters of mirrors
for MLIST in $MIRRORS/*; do
for ALT in $(sed 's/.*\t\([^\t]*\)$/\1/g' "$MLIST" | grep -v "^Custom$"); do
for ALT in $(sed 's/.*\t\([^\t]*\)$/\1/g' "$MLIST" | fgrep -xv 'Custom'); do
if [ "${URL:0:${#ALT}}" == "$ALT" ] ; then
# compose the list of valid mirrors
REST=${URL:${#ALT}}
Expand Down Expand Up @@ -166,25 +166,25 @@ testpack () {
FILEMAGIC=$(file -b $FILENAME)
case $FILENAME in
*.bz2|*.BZ2)
echo $FILEMAGIC | grep -qw "bzip2"
echo $FILEMAGIC | fgrep -qw 'bzip2'
;;
*.gz|*.GZ|*.tgz|*.TGZ)
echo $FILEMAGIC | grep -qw "gzip"
echo $FILEMAGIC | fgrep -qw 'gzip'
;;
*.z|*.Z)
echo $FILEMAGIC | grep -qw "compress"
echo $FILEMAGIC | fgrep -qw 'compress'
;;
*.zip|*.ZIP)
echo $FILEMAGIC | grep -qw "Zip"
echo $FILEMAGIC | fgrep -qw 'Zip'
;;
*.rpm|*.RPM)
echo $FILEMAGIC | grep -qw "RPM"
echo $FILEMAGIC | fgrep -qw 'RPM'
;;
*.CAB|*.cab)
echo $FILEMAGIC | grep -qw "Cabinet"
echo $FILEMAGIC | fgrep -qw 'Cabinet'
;;
*.xz|*.XZ)
echo $FILEMAGIC | grep -qw "XZ"
echo $FILEMAGIC | fgrep -qw 'XZ'
;;
*)
# we don't know how to handle this type of file
Expand Down
2 changes: 1 addition & 1 deletion libs/edit.lunar
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ patch_it () {
PATCH="$1"
fi

if [[ -n `echo $PATCH | grep '\.tar'` ]] ; then
if [[ -n `echo $PATCH | fgrep '.tar'` ]] ; then
TARCMD="tar x -O"
else
TARCMD="cat"
Expand Down
4 changes: 2 additions & 2 deletions libs/kernel.lunar
Original file line number Diff line number Diff line change
Expand Up @@ -93,11 +93,11 @@ kernel_option_present() {
esac

if [ -n "$KERNEL_VALUE" ]; then
if $CAT "$KERNEL_CONFIG" | grep -Eq "^$KERNEL_OPTION=\"$KERNEL_VALUE\""; then
if $CAT "$KERNEL_CONFIG" | grep -q "^$KERNEL_OPTION=\"$KERNEL_VALUE\""; then
return 0
fi
else
if $CAT "$KERNEL_CONFIG" | grep -Eq "^$KERNEL_OPTION=(y|m)$"; then
if $CAT "$KERNEL_CONFIG" | grep -q "^$KERNEL_OPTION=[ym]$"; then
return 0
fi
fi
Expand Down
2 changes: 1 addition & 1 deletion libs/locking.lunar
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ lin_locked() {
debug_msg "lin_locked ($@)"
[ -f /var/lock/installing.$1 ] &&
ps `cat "/var/lock/installing.$1"` |
grep -q "lin"
fgrep -wq 'lin'
}


Expand Down
2 changes: 1 addition & 1 deletion libs/logging.lunar
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ progress() {
X="############################################################"
Y=" "
OLDSZ=$(xzbz -dc $OLDLOG | wc -c)
OLDTIMES=($(xzbz -dc $OLDLOG | grep 'Mark Compile ' | cut -d \" -f6 | while read TIME ; do date +%s -d "$TIME" ; done))
OLDTIMES=($(xzbz -dc $OLDLOG | fgrep 'Mark Compile ' | cut -d \" -f6 | while read TIME ; do date +%s -d "$TIME" ; done))
CTIME=$((${OLDTIMES[1]} - ${OLDTIMES[0]}))
echo "Last compile time: $((CTIME / 60))m$((CTIME % 60))s"
while true ; do
Expand Down
2 changes: 1 addition & 1 deletion libs/messages.lunar
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ debug_msg() {
fi
set | grep '^[A-Z]' | sed 's/^/VAR /' > $TMPDIR/l_debug_var.$$
diff -U0 $TMPDIR/l_debug_var.$$.old $TMPDIR/l_debug_var.$$ | \
grep -v "^@@" | grep "VAR" | tee -a $TMPDIR/lp_debuglog.$$ >&2
grep -v '^@@' | fgrep 'VAR' | tee -a $TMPDIR/lp_debuglog.$$ >&2
fi
fi
}
Expand Down
10 changes: 5 additions & 5 deletions libs/misc.lunar
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ ld_add() {
debug_msg "ld_add ($@)"

if [ ! -z "$1" ] && [ -d "$1" ] ; then
if ! grep -q "$1" /etc/ld.so.conf; then
if ! fgrep -xq "$1" /etc/ld.so.conf; then
verbose_msg "Adding $1 to ld.so.conf"
echo "$1" >> /etc/ld.so.conf
ldconfig
Expand All @@ -48,12 +48,12 @@ ld_remove() {
debug_msg "ld_remove ($@)"

if [ ! -z "$1" ]; then
if grep -q "$1" /etc/ld.so.conf ; then
if fgrep -xq "$1" /etc/ld.so.conf ; then

TMP_LD_CONF=$(temp_create "ldsoconf")
verbose_msg "Removing $1 from ld.so.conf"

grep -v "$1" /etc/ld.so.conf > $TMP_LD_CONF
fgrep -xv "$1" /etc/ld.so.conf > $TMP_LD_CONF
cat "$TMP_LD_CONF" > /etc/ld.so.conf
ldconfig

Expand Down Expand Up @@ -207,9 +207,9 @@ custom_filters()
last_kernel()
{
if [ -f /usr/src/linux/include/linux/utsrelease.h ]; then
grep UTS_RELEASE /usr/src/linux/include/linux/utsrelease.h | cut -d'"' -f2
fgrep UTS_RELEASE /usr/src/linux/include/linux/utsrelease.h | cut -d'"' -f2
else
grep UTS_RELEASE /usr/src/linux/include/linux/version.h | cut -d'"' -f2
fgrep UTS_RELEASE /usr/src/linux/include/linux/version.h | cut -d'"' -f2
fi
}

Expand Down
Loading