* Re: [devel] [git update] packages/alterator-ovz: heads/master @ 2007-03-11 15:07 ` Dmitry V. Levin 2007-03-11 16:20 ` Sergey Vlasov 2007-03-11 18:46 ` Eugene Ostapets 0 siblings, 2 replies; 6+ messages in thread From: Dmitry V. Levin @ 2007-03-11 15:07 UTC (permalink / raw) To: ALT Devel discussion list [-- Attachment #1: Type: text/plain, Size: 1659 bytes --] On Sun, Mar 11, 2007 at 05:32:21PM +0300, Konstantin A. Lepikhov wrote: > Update of /people/lakostis/packages/alterator-ovz.git > > Changes statistics since `a96538d610d45f2f6b1cae976a197fd1e49e68b6' follows: > alterator-ovz/backend3/ovz-ve | 11 +++++++++-- > 1 files changed, 9 insertions(+), 2 deletions(-) > > Changelog since `a96538d610d45f2f6b1cae976a197fd1e49e68b6' follows: > commit a2d633bece69be29cdd27646f52c227488c3b578 > Author: Konstantin A. Lepikhov <lakostis@altlinux.ru> > Date: Sun Mar 11 16:56:44 2007 +0300 > > - fix case where ve name is missing. > [...] > @@ -20,7 +20,13 @@ list_ve() > > get_veid() > { > - vzlist -aHoname,veid|tr -s ' ' '\t'| grep "^$1[[:space:]]"| cut -f2 > + case "$1" in > + [0-9]*) echo "$1" > + ;; > + *) > + vzlist -aHoname,veid|tr -s ' ' '\t'| grep "^$1[[:space:]]"| cut -f2 > + ;; > + esac > } > > get_ve_status() Проверка на численное значение вида [0-9]* не очень хороша тем, что 3foo подходит под эту проверку, но при этом не является числом. В /usr/bin/hsh-sh-functions есть специальная функция, используемая для проверки численного значения ключа: opt_check_number() { [ -z "$(printf %s "$2" |tr -d '[0-9]')" ] && [ "$2" -gt 0 ] 2>/dev/null || Fatal "$1: $2: invalid number." printf %s "$2" } По аналогии get_veid можно переписать так: get_veid() { local name="$1"; shift [ -n "$name" ] || return 1 if [ -z "$(printf %s "$name" |tr -d '[0-9]')" ] && [ "$name" -gt 0 ] 2>/dev/null; then echo "$name" else vzlist -aH -oveid,name | awk "-vname=$name" '$2==name{print $1;exit}' fi } -- ldv [-- Attachment #2: Type: application/pgp-signature, Size: 189 bytes --] ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [devel] [git update] packages/alterator-ovz: heads/master 2007-03-11 15:07 ` [devel] [git update] packages/alterator-ovz: heads/master Dmitry V. Levin @ 2007-03-11 16:20 ` Sergey Vlasov 2007-03-11 18:37 ` Dmitry V. Levin 2007-03-11 18:46 ` Eugene Ostapets 1 sibling, 1 reply; 6+ messages in thread From: Sergey Vlasov @ 2007-03-11 16:20 UTC (permalink / raw) To: devel [-- Attachment #1: Type: text/plain, Size: 1218 bytes --] On Sun, Mar 11, 2007 at 06:07:43PM +0300, Dmitry V. Levin wrote: > Проверка на численное значение вида [0-9]* не очень хороша тем, что > 3foo подходит под эту проверку, но при этом не является числом. > > В /usr/bin/hsh-sh-functions есть специальная функция, используемая > для проверки численного значения ключа: > > opt_check_number() > { > [ -z "$(printf %s "$2" |tr -d '[0-9]')" ] && > [ "$2" -gt 0 ] 2>/dev/null || > Fatal "$1: $2: invalid number." > printf %s "$2" > } > > По аналогии get_veid можно переписать так: > > get_veid() > { > local name="$1"; shift > [ -n "$name" ] || return 1 > if [ -z "$(printf %s "$name" |tr -d '[0-9]')" ] && > [ "$name" -gt 0 ] 2>/dev/null; then В принципе можно выполнить подобную проверку и без порождения дополнительных процессов: if [ -n "${name##*[!0-9]*}" ] && [ "$name" -gt 0 ] 2>/dev/null; then Однако оба варианта всё равно пропускают строки, начинающиеся с 0, которые могут затем быть интерпретированы как восьмеричные числа (либо как ошибочные, если далее в строке встречаются 8 или 9). > echo "$name" > else > vzlist -aH -oveid,name | > awk "-vname=$name" '$2==name{print $1;exit}' > fi > } [-- Attachment #2: Digital signature --] [-- Type: application/pgp-signature, Size: 189 bytes --] ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [devel] [git update] packages/alterator-ovz: heads/master 2007-03-11 16:20 ` Sergey Vlasov @ 2007-03-11 18:37 ` Dmitry V. Levin 0 siblings, 0 replies; 6+ messages in thread From: Dmitry V. Levin @ 2007-03-11 18:37 UTC (permalink / raw) To: ALT Devel discussion list [-- Attachment #1: Type: text/plain, Size: 1394 bytes --] On Sun, Mar 11, 2007 at 07:20:06PM +0300, Sergey Vlasov wrote: > On Sun, Mar 11, 2007 at 06:07:43PM +0300, Dmitry V. Levin wrote: > > Проверка на численное значение вида [0-9]* не очень хороша тем, что > > 3foo подходит под эту проверку, но при этом не является числом. > > > > В /usr/bin/hsh-sh-functions есть специальная функция, используемая > > для проверки численного значения ключа: > > > > opt_check_number() > > { > > [ -z "$(printf %s "$2" |tr -d '[0-9]')" ] && > > [ "$2" -gt 0 ] 2>/dev/null || > > Fatal "$1: $2: invalid number." > > printf %s "$2" > > } > > > > По аналогии get_veid можно переписать так: > > > > get_veid() > > { > > local name="$1"; shift > > [ -n "$name" ] || return 1 > > if [ -z "$(printf %s "$name" |tr -d '[0-9]')" ] && > > [ "$name" -gt 0 ] 2>/dev/null; then > > В принципе можно выполнить подобную проверку и без порождения > дополнительных процессов: > > if [ -n "${name##*[!0-9]*}" ] && > [ "$name" -gt 0 ] 2>/dev/null; then И dash это тоже понимает. > Однако оба варианта всё равно пропускают строки, начинающиеся с 0, > которые могут затем быть интерпретированы как восьмеричные числа > (либо как ошибочные, если далее в строке встречаются 8 или 9). В данном случае этого риска, скорее всего, нет, поскольку vzctl использует strtol(,,10). Но вообще это надо иметь в виду. -- ldv [-- Attachment #2: Type: application/pgp-signature, Size: 189 bytes --] ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [devel] [git update] packages/alterator-ovz: heads/master 2007-03-11 15:07 ` [devel] [git update] packages/alterator-ovz: heads/master Dmitry V. Levin 2007-03-11 16:20 ` Sergey Vlasov @ 2007-03-11 18:46 ` Eugene Ostapets 2007-03-11 19:02 ` Sergey Vlasov 1 sibling, 1 reply; 6+ messages in thread From: Eugene Ostapets @ 2007-03-11 18:46 UTC (permalink / raw) To: ALT Devel discussion list 2007/3/11, Dmitry V. Levin <ldv altlinux.org>: > On Sun, Mar 11, 2007 at 05:32:21PM +0300, Konstantin A. Lepikhov wrote: > > Update of /people/lakostis/packages/alterator-ovz.git > > > > Changes statistics since `a96538d610d45f2f6b1cae976a197fd1e49e68b6' follows: > > alterator-ovz/backend3/ovz-ve | 11 +++++++++-- > > 1 files changed, 9 insertions(+), 2 deletions(-) > > > > Changelog since `a96538d610d45f2f6b1cae976a197fd1e49e68b6' follows: > > commit a2d633bece69be29cdd27646f52c227488c3b578 > > Author: Konstantin A. Lepikhov <lakostis@altlinux.ru> > > Date: Sun Mar 11 16:56:44 2007 +0300 > > > > - fix case where ve name is missing. > > > [...] > > @@ -20,7 +20,13 @@ list_ve() > > > > get_veid() > > { > > - vzlist -aHoname,veid|tr -s ' ' '\t'| grep "^$1[[:space:]]"| cut -f2 > > + case "$1" in > > + [0-9]*) echo "$1" > > + ;; > > + *) > > + vzlist -aHoname,veid|tr -s ' ' '\t'| grep "^$1[[:space:]]"| cut -f2 > > + ;; > > + esac > > } > > > > get_ve_status() > > Проверка на численное значение вида [0-9]* не очень хороша тем, что > 3foo подходит под эту проверку, но при этом не является числом. Что-то оказалось непроцитарованным? В приведенном примере я не вижу такой проверки... В рамках regexp 3foo не пройдет по маске [0-9]*, в каком контексте приведено замечание? -- С уважением, Евгений Остапец uin: 23747217 jid: eugene_ostapets@jabber.ru ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [devel] [git update] packages/alterator-ovz: heads/master 2007-03-11 18:46 ` Eugene Ostapets @ 2007-03-11 19:02 ` Sergey Vlasov 2007-03-11 20:24 ` Eugene Ostapets 0 siblings, 1 reply; 6+ messages in thread From: Sergey Vlasov @ 2007-03-11 19:02 UTC (permalink / raw) To: devel [-- Attachment #1: Type: text/plain, Size: 826 bytes --] On Sun, Mar 11, 2007 at 08:46:47PM +0200, Eugene Ostapets wrote: > > > + case "$1" in > > > + [0-9]*) echo "$1" > > > + ;; > > > + *) > > > + vzlist -aHoname,veid|tr -s ' ' '\t'| grep "^$1[[:space:]]"| cut -f2 > > > + ;; > > > + esac > > > } > > > > > > get_ve_status() > > > > Проверка на численное значение вида [0-9]* не очень хороша тем, что > > 3foo подходит под эту проверку, но при этом не является числом. > Что-то оказалось непроцитарованным? В приведенном примере я не вижу > такой проверки... В рамках regexp 3foo не пройдет по маске [0-9]*, в > каком контексте приведено замечание? Однако в данном случае используется не regexp, а shell pattern (впрочем, regexp был бы тоже неверным, поскольку допускает и пустые строки). [-- Attachment #2: Digital signature --] [-- Type: application/pgp-signature, Size: 189 bytes --] ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [devel] [git update] packages/alterator-ovz: heads/master 2007-03-11 19:02 ` Sergey Vlasov @ 2007-03-11 20:24 ` Eugene Ostapets 0 siblings, 0 replies; 6+ messages in thread From: Eugene Ostapets @ 2007-03-11 20:24 UTC (permalink / raw) To: ALT Devel discussion list 11.03.07, Sergey Vlasov<vsu altlinux.ru> написал(а): > Однако в данном случае используется не regexp, а shell pattern > (впрочем, regexp был бы тоже неверным, поскольку допускает и пустые > строки). Ненавижу shell, ненавижу regexp, ненавижу perl... Впрочем я пьян и это не имеет знаечения... -- С уважением, Евгений Остапец uin: 23747217 jid: eugene_ostapets@jabber.ru ^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2007-03-11 20:24 UTC | newest] Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 2007-03-11 15:07 ` [devel] [git update] packages/alterator-ovz: heads/master Dmitry V. Levin 2007-03-11 16:20 ` Sergey Vlasov 2007-03-11 18:37 ` Dmitry V. Levin 2007-03-11 18:46 ` Eugene Ostapets 2007-03-11 19:02 ` Sergey Vlasov 2007-03-11 20:24 ` Eugene Ostapets
ALT Linux Team development discussions This inbox may be cloned and mirrored by anyone: git clone --mirror http://lore.altlinux.org/devel/0 devel/git/0.git # If you have public-inbox 1.1+ installed, you may # initialize and index your mirror using the following commands: public-inbox-init -V2 devel devel/ http://lore.altlinux.org/devel \ devel@altlinux.org devel@altlinux.ru devel@lists.altlinux.org devel@lists.altlinux.ru devel@linux.iplabs.ru mandrake-russian@linuxteam.iplabs.ru sisyphus@linuxteam.iplabs.ru public-inbox-index devel Example config snippet for mirrors. Newsgroup available over NNTP: nntp://lore.altlinux.org/org.altlinux.lists.devel AGPL code for this site: git clone https://public-inbox.org/public-inbox.git