From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from lists.gentoo.org (pigeon.gentoo.org [208.92.234.80]) by finch.gentoo.org (Postfix) with ESMTP id CAD07139737 for ; Tue, 11 Aug 2015 18:38:20 +0000 (UTC) Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id B953C14217; Tue, 11 Aug 2015 18:38:00 +0000 (UTC) Received: from smtp.gentoo.org (smtp.gentoo.org [140.211.166.183]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by pigeon.gentoo.org (Postfix) with ESMTPS id F3A9A14203 for ; Tue, 11 Aug 2015 18:37:58 +0000 (UTC) Received: from oystercatcher.gentoo.org (unknown [IPv6:2a01:4f8:202:4333:225:90ff:fed9:fc84]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by smtp.gentoo.org (Postfix) with ESMTPS id 165B0340D5D for ; Tue, 11 Aug 2015 18:37:58 +0000 (UTC) Received: from localhost.localdomain (localhost [127.0.0.1]) by oystercatcher.gentoo.org (Postfix) with ESMTP id 6215015D for ; Tue, 11 Aug 2015 18:37:53 +0000 (UTC) From: "Richard Farina" To: gentoo-commits@lists.gentoo.org Content-Transfer-Encoding: 8bit Content-type: text/plain; charset=UTF-8 Reply-To: gentoo-dev@lists.gentoo.org, "Richard Farina" Message-ID: <1439317276.a6202ee3e4a2098fc17fd64ac3aad46353cff5dd.zerochaos@gentoo> Subject: [gentoo-commits] proj/genkernel:master commit in: defaults/ X-VCS-Repository: proj/genkernel X-VCS-Files: defaults/initrd.scripts X-VCS-Directories: defaults/ X-VCS-Committer: zerochaos X-VCS-Committer-Name: Richard Farina X-VCS-Revision: a6202ee3e4a2098fc17fd64ac3aad46353cff5dd X-VCS-Branch: master Date: Tue, 11 Aug 2015 18:37:53 +0000 (UTC) Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-Id: Gentoo Linux mail X-BeenThere: gentoo-commits@lists.gentoo.org X-Archives-Salt: 878d62d2-ee4e-4aff-ad8a-f427090c3444 X-Archives-Hash: 5a0e94b3780a300ae73be648d07f9ef5 commit: a6202ee3e4a2098fc17fd64ac3aad46353cff5dd Author: Fernando Reyes (likewhoa) missionaccomplish com> AuthorDate: Mon Jun 23 20:03:36 2014 +0000 Commit: Richard Farina gentoo org> CommitDate: Tue Aug 11 18:21:16 2015 +0000 URL: https://gitweb.gentoo.org/proj/genkernel.git/commit/?id=a6202ee3 Introduced a new funtion to test for numeric values that that our changes_fs doesn't fail when non-numeric values are given, also the styling of changes_fs was changed to reflect new logic. defaults/initrd.scripts | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) diff --git a/defaults/initrd.scripts b/defaults/initrd.scripts index c258c00..02842bf 100644 --- a/defaults/initrd.scripts +++ b/defaults/initrd.scripts @@ -345,6 +345,18 @@ conf_rc_no_umounts() { fi } +# is_int "$A" ["$B"..] +# NOTE we consider a leading 0 false as it would be interpreted as octal +is_int(){ + local i + for i; do + case $i in + ''|*[!0-9]*|0?*) return 1 ;; + *) : + esac + done +} + # Function to create an ext2 fs on $CHANGESDEV, $CHANGESMNT mountpoint create_changefs() { local size @@ -352,11 +364,12 @@ create_changefs() { while :; do read -p '<< Size of file (Press Enter for default 256 Mb): ' size - [ -n "$size" ] || size=256 - - size=$size + size=${size:-256} - if [ 15 -ge "$size" ]; then + if ! is_int $size; then + bad_msg "Non numeric value given for size, try again" + continue + elif [ 15 -ge "$size" ]; then bad_msg "Please give a size of at least 16 Megabytes" else if dd if=/dev/zero "of=$CHANGESMNT$AUFS_CHANGESFILE" bs=1M count="$size" &>/dev/null; then