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

replace awk with gawk #79

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
46 changes: 23 additions & 23 deletions apt-cyg
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ function find-workspace {
# default working directory and mirror

# work wherever setup worked last, if possible
cache=$(awk '
cache=$(gawk '
BEGIN {
RS = "\n\\<"
FS = "\n\t"
Expand All @@ -143,7 +143,7 @@ function find-workspace {
}
' /etc/setup/setup.rc)

mirror=$(awk '
mirror=$(gawk '
/last-mirror/ {
getline
print $1
Expand Down Expand Up @@ -206,7 +206,7 @@ function apt-category {
find-workspace
for pkg in "${pks[@]}"
do
awk '
gawk '
$1 == "@" {
pck = $2
}
Expand All @@ -222,10 +222,10 @@ function apt-list {
for pkg in "${pks[@]}"
do
let sbq++ && echo
awk 'NR>1 && $1~pkg && $0=$1' pkg="$pkg" /etc/setup/installed.db
gawk 'NR>1 && $1~pkg && $0=$1' pkg="$pkg" /etc/setup/installed.db
done
let sbq && return
awk 'NR>1 && $0=$1' /etc/setup/installed.db
gawk 'NR>1 && $0=$1' /etc/setup/installed.db
}

function apt-listall {
Expand All @@ -235,7 +235,7 @@ function apt-listall {
for pkg in "${pks[@]}"
do
let sbq++ && echo
awk '$1~pkg && $0=$1' RS='\n\n@ ' FS='\n' pkg="$pkg" setup.ini
gawk '$1~pkg && $0=$1' RS='\n\n@ ' FS='\n' pkg="$pkg" setup.ini
done
}

Expand All @@ -260,7 +260,7 @@ function apt-show {
for pkg in "${pks[@]}"
do
(( notfirst++ )) && echo
awk '
gawk '
$1 == query {
print
fd++
Expand All @@ -278,7 +278,7 @@ function apt-depends {
check-packages
for pkg in "${pks[@]}"
do
awk '
gawk '
@include "join"
$1 == "@" {
apg = $2
Expand Down Expand Up @@ -312,7 +312,7 @@ function apt-rdepends {
find-workspace
for pkg in "${pks[@]}"
do
awk '
gawk '
@include "join"
$1 == "@" {
apg = $2
Expand Down Expand Up @@ -358,7 +358,7 @@ function download {
pkg=$1
# look for package and save desc file

awk '$1 == pc' RS='\n\n@ ' FS='\n' pc=$pkg setup.ini > desc
gawk '$1 == pc' RS='\n\n@ ' FS='\n' pc=$pkg setup.ini > desc
if [ ! -s desc ]
then
echo Unable to locate package $pkg
Expand All @@ -368,7 +368,7 @@ function download {
# download and unpack the bz2 or xz file

# pick the latest version, which comes first
set -- $(awk '$1 == "install:"' desc)
set -- $(gawk '$1 == "install:"' desc)
if (( ! $# ))
then
echo 'Could not find "install" in package description: obsolete package?'
Expand Down Expand Up @@ -425,7 +425,7 @@ function apt-searchall {
do
printf -v qs 'text=1&arch=%s&grep=%s' $arch "$pkg"
wget -O matches cygwin.com/cgi-bin2/package-grep.cgi?"$qs"
awk '
gawk '
NR == 1 {next}
mc[$1]++ {next}
/-debuginfo-/ {next}
Expand Down Expand Up @@ -458,7 +458,7 @@ function apt-install {
tar -x -C / -f $bn
# update the package database

awk '
gawk '
ins != 1 && pkg < $1 {
print pkg, bz, 0
ins = 1
Expand All @@ -467,14 +467,14 @@ function apt-install {
END {
if (ins != 1) print pkg, bz, 0
}
' pkg="$pkg" bz=$bn /etc/setup/installed.db > /tmp/awk.$$
' pkg="$pkg" bz=$bn /etc/setup/installed.db > /tmp/gawk.$$
mv /etc/setup/installed.db /etc/setup/installed.db-save
mv /tmp/awk.$$ /etc/setup/installed.db
mv /tmp/gawk.$$ /etc/setup/installed.db

[ -v nodeps ] && continue
# recursively install required packages

requires=$(awk '$1=="requires", $0=$2' FS=': ' desc)
requires=$(gawk '$1=="requires", $0=$2' FS=': ' desc)
cd ~-
wr=0
if [[ $requires ]]
Expand Down Expand Up @@ -513,7 +513,7 @@ function apt-install {
function apt-remove {
check-packages
cd /etc
cygcheck awk bash bunzip2 grep gzip mv sed tar xz > setup/essential.lst
cygcheck gawk bash bunzip2 grep gzip mv sed tar xz > setup/essential.lst
for pkg in "${pks[@]}"
do

Expand All @@ -529,7 +529,7 @@ function apt-remove {
exit 1
fi
gzip -dk setup/"$pkg".lst.gz
awk '
gawk '
NR == FNR {
if ($NF) ess[$NF]
next
Expand Down Expand Up @@ -557,7 +557,7 @@ function apt-remove {
[ -d /$each ] && rmdir --i /$each
done
rm -f setup/"$pkg".lst.gz postinstall/"$pkg".sh.done
awk -i inplace '$1 != ENVIRON["pkg"]' setup/installed.db
gawk -i inplace '$1 != ENVIRON["pkg"]' setup/installed.db
echo Package $pkg removed
fi
rm setup/"$pkg".lst
Expand All @@ -573,7 +573,7 @@ function apt-remove {
function apt-mirror {
if [ "$pks" ]
then
awk -i inplace '
gawk -i inplace '
1
/last-mirror/ {
getline
Expand All @@ -582,7 +582,7 @@ function apt-mirror {
' pks="$pks" /etc/setup/setup.rc
echo Mirror set to "$pks".
else
awk '
gawk '
/last-mirror/ {
getline
print $1
Expand All @@ -595,7 +595,7 @@ function apt-cache {
if [ "$pks" ]
then
vas=$(cygpath -aw "$pks")
awk -i inplace '
gawk -i inplace '
1
/last-cache/ {
getline
Expand All @@ -604,7 +604,7 @@ function apt-cache {
' vas="${vas//\\/\\\\}" /etc/setup/setup.rc
echo Cache set to "$vas".
else
awk '
gawk '
/last-cache/ {
getline
print $1
Expand Down