Github messages for voidlinux
 help / color / mirror / Atom feed
* [PR PATCH] Fix syntax
@ 2021-12-30 11:18 zakariaGatter
  2021-12-30 14:23 ` [PR REVIEW] " sgn
                   ` (4 more replies)
  0 siblings, 5 replies; 6+ messages in thread
From: zakariaGatter @ 2021-12-30 11:18 UTC (permalink / raw)
  To: ml

[-- Attachment #1: Type: text/plain, Size: 423 bytes --]

There is a new pull request by zakariaGatter against master on the void-packages repository

https://github.com/zakariaGatter/void-packages patch-1
https://github.com/void-linux/void-packages/pull/34760

Fix syntax
get rid of extra prosses 'cat' and use builtin bash commands fix some bash syntax (using sh syntax in a bash script)

A patch file from https://github.com/void-linux/void-packages/pull/34760.patch is attached

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: github-pr-patch-1-34760.patch --]
[-- Type: text/x-diff, Size: 7456 bytes --]

From 528cf899b2b34f65b8909bd5198c29c816ed3a6b Mon Sep 17 00:00:00 2001
From: Zakaria Barkouk <zakaria.gatter@gmail.com>
Date: Thu, 30 Dec 2021 12:16:30 +0100
Subject: [PATCH] Fix syntax

get rid of extra prosses 'cat' and use builtin bash commands fix some bash syntax (using sh syntax in a bash script)
---
 xbps-src | 69 +++++++++++++++++++++-----------------------------------
 1 file changed, 26 insertions(+), 43 deletions(-)

diff --git a/xbps-src b/xbps-src
index ff249015ed02..567976bd308e 100755
--- a/xbps-src
+++ b/xbps-src
@@ -9,7 +9,9 @@ print_cross_targets() {
 }
 
 usage() {
-    cat << _EOF
+while read ; do
+    printf "%s\n" "$REPLY"
+done <<- _EOF
 $PROGNAME: [options] <target> [arguments]
 
 Targets: (only one may be specified)
@@ -268,9 +270,7 @@ check_build_requirements() {
 }
 
 chroot_check() {
-    if [ -f $XBPS_MASTERDIR/.xbps_chroot_init -o "$XBPS_CHROOT_CMD" = "ethereal" ]; then
-        export CHROOT_READY=1
-    fi
+    [ -f $XBPS_MASTERDIR/.xbps_chroot_init ] || [ "$XBPS_CHROOT_CMD" = "ethereal" ] && export CHROOT_READY=1
 }
 
 check_native_arch() {
@@ -299,12 +299,8 @@ masterdir_zap() {
 
 exit_func() {
     wait
-    if [ "$sourcepkg" ]; then
-        remove_pkg $XBPS_CROSS_BUILD
-    fi
-    if [ -z "$IN_CHROOT" ]; then
-        msg_red "xbps-src: a failure has occurred! exiting...\n"
-    fi
+    [ "$sourcepkg" ] && remove_pkg $XBPS_CROSS_BUILD
+    [ "$IN_CHROOT" ] || msg_red "xbps-src: a failure has occurred! exiting...\n"
     exit 2
 }
 
@@ -401,9 +397,7 @@ shift $(($OPTIND - 1))
 # Check if stdout is a tty; if false disable colors.
 test -t 1 || export NOCOLORS=1
 # http://no-color.org
-if [ "${NO_COLOR+x}" ]; then
-    export NOCOLORS=1
-fi
+[ "${NO_COLOR+x}" ] && export NOCOLORS=1
 
 # sane umask
 umask 022
@@ -438,9 +432,8 @@ else
         readonly XBPS_DISTDIR="${_distdir}"
     fi
     # Read defaults and then the local configuration file
-    if [ -f $XBPS_DISTDIR/etc/defaults.conf ]; then
-        . $XBPS_DISTDIR/etc/defaults.conf
-    fi
+    [ -f $XBPS_DISTDIR/etc/defaults.conf ] && source $XBPS_DISTDIR/etc/defaults.conf
+    
     if [ -n "$XBPS_ARG_CONFIG" -a -s $XBPS_DISTDIR/etc/conf.$XBPS_ARG_CONFIG ]; then
         # If specified, read custom user configuration...
         readonly XBPS_CONFIG_FILE=$XBPS_DISTDIR/etc/conf.$XBPS_ARG_CONFIG
@@ -493,18 +486,18 @@ fi
 
 # Forbid root unless XBPS_ALLOW_CHROOT_BREAKOUT is set
 # (for CI).
-if [ -z "$IN_CHROOT" -a "$UID" -eq 0 -a -z "$XBPS_ALLOW_CHROOT_BREAKOUT" ]; then
+if [ -z "$IN_CHROOT" ] && [ "$UID" -eq 0 ] && [ -z "$XBPS_ALLOW_CHROOT_BREAKOUT" ]; then
     echo "ERROR: xbps-src cannot be used as root." 1>&2
     exit 1
 fi
 
 # if XBPS_MASTERDIR unset, defaults to $XBPS_DISTDIR/masterdir.
 : ${XBPS_MASTERDIR:=$XBPS_DISTDIR/masterdir}
-[ ! -d $XBPS_MASTERDIR ] &&  mkdir -p $XBPS_MASTERDIR
+[ -d $XBPS_MASTERDIR ] || mkdir -p $XBPS_MASTERDIR
 
 # if XBPS_HOSTDIR unset, defaults to $XBPS_DISTDIR/hostdir.
 : ${XBPS_HOSTDIR:=$XBPS_DISTDIR/hostdir}
-[ ! -d $XBPS_HOSTDIR ] && mkdir -p $XBPS_HOSTDIR
+[ -d $XBPS_HOSTDIR ] || mkdir -p $XBPS_HOSTDIR
 
 if [ -d "$XBPS_MASTERDIR" -a ! -w "$XBPS_MASTERDIR" ]; then
     echo "ERROR: can't write to masterdir $XBPS_MASTERDIR." 1>&2
@@ -521,7 +514,7 @@ elif [ -z "$XBPS_USE_BUILD_MTIME" ] || [ "$XBPS_USE_GIT_REVS" ]; then
     exit 1
 fi
 
-if [ -n "$XBPS_HOSTDIR" ]; then
+if [ "$XBPS_HOSTDIR" ]; then
     export XBPS_REPOSITORY=$XBPS_HOSTDIR/binpkgs
     readonly XBPS_SRCDISTDIR=$XBPS_HOSTDIR/sources
 else
@@ -553,9 +546,7 @@ readonly XBPS_LIBEXECDIR=$XBPS_COMMONDIR/xbps-src/libexec
 readonly XBPS_BUILDHELPERDIR=$XBPS_COMMONDIR/build-helper
 
 readonly XBPS_TARGET="$1"
-if [ "$2" ]; then
-    XBPS_TARGET_PKG="${2##*/}"
-fi
+[ "$2" ] && XBPS_TARGET_PKG="${2##*/}"
 
 # Check for CHROOT_READY and set up XBPS_ARCH environment var for xbps.
 chroot_check
@@ -596,9 +587,7 @@ if [ "$XBPS_ARCH" ]; then
 fi
 # At this point if XBPS_TARGET_MACHINE isn't defined we assume
 # it's a native build.
-if [ -z "$XBPS_TARGET_MACHINE" ]; then
-        export XBPS_TARGET_MACHINE=$XBPS_MACHINE
-fi
+[ "$XBPS_TARGET_MACHINE" ] || export XBPS_TARGET_MACHINE=$XBPS_MACHINE
 
 if [ "$IN_CHROOT" ]; then
     readonly XBPS_UHELPER_CMD="xbps-uhelper"
@@ -643,25 +632,21 @@ export XBPS_SHUTILSDIR XBPS_CROSSPFDIR XBPS_TRIGGERSDIR \
 
 for i in REPOSITORY DESTDIR BUILDDIR SRCDISTDIR; do
     eval val="\$XBPS_$i"
-    if [ ! -d "$val" ]; then
-        mkdir -p $val
-    fi
+    [ -d "$val" ] || mkdir -p $val
     unset val
 done
 
 # A temporary masterdir requires xbps-uchroot(1) and -O to use overlayfs
 # on tmpfs (available with xbps-0.45).
-if [ -z "$IN_CHROOT" -a -n "$XBPS_TEMP_MASTERDIR" ]; then
+if [ -z "$IN_CHROOT" ] && [ -n "$XBPS_TEMP_MASTERDIR" ]; then
     export XBPS_CHROOT_CMD="uchroot"
     export XBPS_CHROOT_CMD_ARGS+=" -O"
 fi
 #
 # Sanitize PATH.
 #
-if [ -z "$IN_CHROOT" ]; then
-    # In non chroot case always prefer host tools.
-    export PATH="$PATH:$XBPS_MASTERDIR/usr/bin"
-fi
+# In non chroot case always prefer host tools.
+[ "$IN_CHROOT" ] || export PATH="$PATH:$XBPS_MASTERDIR/usr/bin"
 
 #
 # Set up ccache
@@ -702,9 +687,7 @@ done
 
 if [ -z "$IN_CHROOT" ]; then
     trap 'exit_func' INT TERM
-    if [ -n "$XBPS_DISTFILES_MIRROR" ]; then
-        setup_distfiles_mirror
-    fi
+    [ "$XBPS_DISTFILES_MIRROR" ] && setup_distfiles_mirror
 fi
 
 reconfigure_base_chroot
@@ -717,7 +700,7 @@ case "$XBPS_TARGET" in
         install_base_chroot ${XBPS_TARGET_PKG:=$XBPS_MACHINE}
         ;;
     bootstrap)
-        if [ -n "$XBPS_CHECK_PKGS" ]; then
+        if [ "$XBPS_CHECK_PKGS" ]; then
             msg_error "xbps-src: disable tests for bootstrap\n"
             exit 1
         fi
@@ -735,7 +718,7 @@ case "$XBPS_TARGET" in
         install_base_chroot ${XBPS_TARGET_PKG:=$XBPS_MACHINE}
         ;;
     bootstrap-update)
-        if [ -n "$CHROOT_READY" -a -z "$IN_CHROOT" ]; then
+        if [ "$CHROOT_READY" ] && [ -z "$IN_CHROOT" ]; then
             chroot_handler bootstrap-update
         else
             chroot_sync_repodata
@@ -748,7 +731,7 @@ case "$XBPS_TARGET" in
         ;;
     clean)
         if [ -z "$XBPS_TARGET_PKG" ]; then
-            if [ -n "$CHROOT_READY" -a -z "$IN_CHROOT" ]; then
+            if [ "$CHROOT_READY" ] && [ -z "$IN_CHROOT" ]; then
                 chroot_handler remove-autodeps
             else
                 remove_pkg_autodeps
@@ -763,7 +746,7 @@ case "$XBPS_TARGET" in
             mkdir -p $XBPS_MASTERDIR/tmp
         else
             read_pkg
-            if [ -n "$CHROOT_READY" -a -z "$IN_CHROOT" ]; then
+            if [ "$CHROOT_READY" ] && [ -z "$IN_CHROOT" ]; then
                 chroot_handler $XBPS_TARGET $XBPS_TARGET_PKG || exit $?
             else
                 if declare -f do_clean >/dev/null; then
@@ -783,7 +766,7 @@ case "$XBPS_TARGET" in
         consistency_check
         ;;
     remove-autodeps)
-        if [ -n "$CHROOT_READY" -a -z "$IN_CHROOT" ]; then
+        if [ "$CHROOT_READY" ] && [ -z "$IN_CHROOT" ]; then
             chroot_handler remove-autodeps
         else
             remove_pkg_autodeps
@@ -794,7 +777,7 @@ case "$XBPS_TARGET" in
             export XBPS_CHECK_PKGS=full
         fi
         read_pkg
-        if [ -n "$CHROOT_READY" -a -z "$IN_CHROOT" ]; then
+        if [ -n "$CHROOT_READY" ] && [ -z "$IN_CHROOT" ]; then
             chroot_handler $XBPS_TARGET $XBPS_TARGET_PKG
         else
             chroot_sync_repodata

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PR REVIEW] Fix syntax
  2021-12-30 11:18 [PR PATCH] Fix syntax zakariaGatter
@ 2021-12-30 14:23 ` sgn
  2021-12-30 14:33 ` zakariaGatter
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: sgn @ 2021-12-30 14:23 UTC (permalink / raw)
  To: ml

[-- Attachment #1: Type: text/plain, Size: 237 bytes --]

New review comment by sgn on void-packages repository

https://github.com/void-linux/void-packages/pull/34760#discussion_r776746268

Comment:
`cat` is fine here, beside a short and rare usage of `usage`, `cat` is easier to reason about.

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PR REVIEW] Fix syntax
  2021-12-30 11:18 [PR PATCH] Fix syntax zakariaGatter
  2021-12-30 14:23 ` [PR REVIEW] " sgn
@ 2021-12-30 14:33 ` zakariaGatter
  2021-12-30 16:23 ` Chocimier
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: zakariaGatter @ 2021-12-30 14:33 UTC (permalink / raw)
  To: ml

[-- Attachment #1: Type: text/plain, Size: 212 bytes --]

New review comment by zakariaGatter on void-packages repository

https://github.com/void-linux/void-packages/pull/34760#discussion_r776750717

Comment:
why using something outside `bash` if it have the solution 

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: Fix syntax
  2021-12-30 11:18 [PR PATCH] Fix syntax zakariaGatter
  2021-12-30 14:23 ` [PR REVIEW] " sgn
  2021-12-30 14:33 ` zakariaGatter
@ 2021-12-30 16:23 ` Chocimier
  2021-12-30 16:23 ` [PR PATCH] [Closed]: " Chocimier
  2021-12-30 16:27 ` zakariaGatter
  4 siblings, 0 replies; 6+ messages in thread
From: Chocimier @ 2021-12-30 16:23 UTC (permalink / raw)
  To: ml

[-- Attachment #1: Type: text/plain, Size: 195 bytes --]

New comment by Chocimier on void-packages repository

https://github.com/void-linux/void-packages/pull/34760#issuecomment-1003096454

Comment:
Nothing's broken, those are just style adjustments.

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PR PATCH] [Closed]: Fix syntax
  2021-12-30 11:18 [PR PATCH] Fix syntax zakariaGatter
                   ` (2 preceding siblings ...)
  2021-12-30 16:23 ` Chocimier
@ 2021-12-30 16:23 ` Chocimier
  2021-12-30 16:27 ` zakariaGatter
  4 siblings, 0 replies; 6+ messages in thread
From: Chocimier @ 2021-12-30 16:23 UTC (permalink / raw)
  To: ml

[-- Attachment #1: Type: text/plain, Size: 260 bytes --]

There's a closed pull request on the void-packages repository

Fix syntax
https://github.com/void-linux/void-packages/pull/34760

Description:
get rid of extra prosses 'cat' and use builtin bash commands fix some bash syntax (using sh syntax in a bash script)

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: Fix syntax
  2021-12-30 11:18 [PR PATCH] Fix syntax zakariaGatter
                   ` (3 preceding siblings ...)
  2021-12-30 16:23 ` [PR PATCH] [Closed]: " Chocimier
@ 2021-12-30 16:27 ` zakariaGatter
  4 siblings, 0 replies; 6+ messages in thread
From: zakariaGatter @ 2021-12-30 16:27 UTC (permalink / raw)
  To: ml

[-- Attachment #1: Type: text/plain, Size: 253 bytes --]

New comment by zakariaGatter on void-packages repository

https://github.com/void-linux/void-packages/pull/34760#issuecomment-1003098051

Comment:
> Nothing's broken, those are just style adjustments.

that what i said on my pull request description 

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2021-12-30 16:27 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-12-30 11:18 [PR PATCH] Fix syntax zakariaGatter
2021-12-30 14:23 ` [PR REVIEW] " sgn
2021-12-30 14:33 ` zakariaGatter
2021-12-30 16:23 ` Chocimier
2021-12-30 16:23 ` [PR PATCH] [Closed]: " Chocimier
2021-12-30 16:27 ` zakariaGatter

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).