From fd07037b229d93c0e909da120ce489c5a6750227 Mon Sep 17 00:00:00 2001 From: Nicolas Boisselier Date: Wed, 16 Nov 2016 21:23:01 +0000 Subject: [PATCH] fix bugs --- bin/dbq | 12 +++++++++++- etc/profile.d/docker.sh | 2 +- etc/profile.d/functions | 7 +++++-- etc/profile.d/mac.sh | 13 ++++++++----- 4 files changed, 25 insertions(+), 9 deletions(-) diff --git a/bin/dbq b/bin/dbq index 99467cc4..e7ff28ce 100755 --- a/bin/dbq +++ b/bin/dbq @@ -125,7 +125,17 @@ $url =~ s,^(\w+://)?([^@]+)@(.*?)$,$1$3, and push(@EXEC,"db=$2"); $url =~ m@^ssh://(.*)$@ and $Opt{ssh} = $1; #die "$url | ",join(' ',@EXEC); -exec('ssh',$Opt{ssh},'/usr/bin/env',"PATH=$ENV{PATH}","PERL5LIB=$ENV{PERL5LIB}",$NAME,map{s/"/\\"/g;'"'.$_.'"'} grep {$_ !~ /^(-+ssh|$Opt{ssh})/} @EXEC) if $Opt{ssh}; +#exec('ssh',$Opt{ssh},". /etc/profile && $NAME",map{s/"/\\"/g;'"'.$_.'"'} grep {$_ !~ /^(-+ssh|$Opt{ssh})/} @EXEC) if $Opt{ssh}; +exec('ssh', + -t STDOUT ? '-t' : '-q', + #'-q', + $Opt{ssh}, + '/usr/bin/env', + "PATH=$ENV{PATH}", + "PERL5LIB=$ENV{PERL5LIB}", + $NAME, + map{s/"/\\"/g;'"'.$_.'"'} grep {$_ !~ /^(-+ssh|$Opt{ssh})/} @EXEC +) if $Opt{ssh}; # # Add options to ARGV diff --git a/etc/profile.d/docker.sh b/etc/profile.d/docker.sh index f74e9dd7..df31f3b5 100644 --- a/etc/profile.d/docker.sh +++ b/etc/profile.d/docker.sh @@ -25,7 +25,7 @@ docker_build() { else perl -ne '/^\s*\#\s*DOCKER_BUILD\s*(.*?)$/ and system "$1"' Dockerfile - echo $FUNCNAME: docker build --rm --force-rm=true -t $@ $docker_name . + echo $FUNCNAME: docker build --rm --force-rm=true --tags $docker_name $@ $docker_name . docker build --rm --force-rm=true -t $@ $docker_name . if [ "$?" != 0 ]; then diff --git a/etc/profile.d/functions b/etc/profile.d/functions index dba6bdf6..cc0b8eea 100644 --- a/etc/profile.d/functions +++ b/etc/profile.d/functions @@ -4,8 +4,11 @@ # ################################################################################# timeout() { - which timeout 1>/dev/null && exec timeout -- $@ - perl -e 'BEGIN{$|=1}; $SIG{ALRM}=sub{exit 1}; alarm(shift @ARGV); system join(" ",@ARGV)' -- $@ + if which timeout 1>/dev/null; then + timeout -- $@ + else + perl -e 'BEGIN{$|=1}; $SIG{ALRM}=sub{exit 1}; alarm(shift @ARGV); system join(" ",@ARGV)' -- $@ + fi } shell_help() { diff --git a/etc/profile.d/mac.sh b/etc/profile.d/mac.sh index d51658eb..4677b45e 100644 --- a/etc/profile.d/mac.sh +++ b/etc/profile.d/mac.sh @@ -65,13 +65,16 @@ killall -KILL SystemUIServer mac_dev_shm() { set -e - local mb=${1?"Usage: $FUNCNAME SIZE in MB [MOUNT DIR (default /dev/shm)]"} + local usage="Usage: $FUNCNAME [SIZE in MB] [MOUNT DIR (default /dev/shm)]" + shell_help_noarg "$usage" "$@" && return 1 + local mb=$1 + !test "$mb" -gt 0 2>/dev/null && shell_help_noarg "$usage" && return 1 local mount_point=${2:-/dev/shm} - local ramdisk_dev=$(hdiutil attach -nomount ram://$((2 * 1024 *$mb))) - diskutil eraseVolume HFS+ RAMDisk "${ramdisk_dev}" + local ramdisk_dev=$(sudo hdiutil attach -nomount ram://$((2 * 1024 *$mb))) + sudo diskutil eraseVolume HFS+ RAMDisk "${ramdisk_dev}" - install -d "${mount_point}" -m 7777 - mount -o noatime -t hfs "${ramdisk_dev}" "${mount_point}" + sudo install -d "${mount_point}" -m 7777 + sudo mount -o noatime -t hfs "${ramdisk_dev}" "${mount_point}" echo "remove with:" echo "umount ${mount_point}" -- 2.47.3