From 3e326d2ce5fe0cb2280ef407f46c3fd85690e33d Mon Sep 17 00:00:00 2001 From: Ole Tange Date: Sat, 28 Apr 2018 21:17:34 +0200 Subject: [PATCH] transpose: Wrapped with main function. --- G/G | 6 ++- transpose/test.sh | 14 +++---- transpose/transpose | 83 ++++++++++++++++++++++--------------- wastebasket/WasteBasket.lua | 3 +- ytv/ytv | 5 ++- 5 files changed, 66 insertions(+), 45 deletions(-) mode change 100644 => 100755 transpose/test.sh diff --git a/G/G b/G/G index 8b6a3f4..0e6056f 100755 --- a/G/G +++ b/G/G @@ -71,7 +71,11 @@ while(@ARGV) { } } -exec join"|", map { "grep ".join(" ", shell_quote(@$_)) } @cmd; +if(@cmd) { + exec join"|", map { "grep ".join(" ", shell_quote(@$_)) } @cmd; +} else { + exec 'cat'; +} sub shell_quote { # Input: diff --git a/transpose/test.sh b/transpose/test.sh old mode 100644 new mode 100755 index 4cf6aa2..3c265b3 --- a/transpose/test.sh +++ b/transpose/test.sh @@ -37,21 +37,21 @@ dotest() { } . `which env_parallel.bash` -env_parallel -r <&2; exit 1; } -block_size=10M -while getopts ":b:d:" o; do - case "${o}" in - d) - d="$(printf "${OPTARG}")" - if [ "'" = "${d}" ] ; then - echo "Delimiter cannot be '" +main() { + block_size=10M + while getopts ":b:d:" o; do + case "${o}" in + d) + d="$(printf "${OPTARG}")" + if [ "'" = "${d}" ] ; then + echo "Delimiter cannot be '" + usage + exit + fi + ;; + b) + block_size="${OPTARG}" + ;; + *) usage - exit - fi - ;; - b) - block_size="${OPTARG}" - ;; - *) - usage - ;; - esac -done -shift $((OPTIND-1)) + ;; + esac + done + shift $((OPTIND-1)) -if [ -z "${d}" ] ; then - d="$(printf "\t")" -fi + if [ -z "${d}" ] ; then + d="$(printf "\t")" + fi -# Sep cannot be ' -file="$@" -first_lines=`tempfile` -if [ -z "$file" ]; then - sep="$(stdin_detect_sep $first_lines)" - (cat $first_lines; rm $first_lines; cat) | - stdin_to_paste_files $block_size "$sep" | super_paste "$sep" -else - sep="$(stdin_detect_sep < "$file" $first_lines)" - rm $first_lines - file_to_paste_files $block_size "$sep" "$file" | super_paste "$sep" -fi + file="$@" + first_lines=`tempfile` + if [ -z "$file" ]; then + sep="$(stdin_detect_sep $first_lines)" + (cat $first_lines; rm $first_lines; cat) | + stdin_to_paste_files $block_size "$sep" | super_paste "$sep" + else + sep="$(stdin_detect_sep < "$file" $first_lines)" + rm $first_lines + file_to_paste_files $block_size "$sep" "$file" | super_paste "$sep" + fi +} + +# Make sure the whole file is read before starting +main "$@" diff --git a/wastebasket/WasteBasket.lua b/wastebasket/WasteBasket.lua index a56469f..5a9c4f6 100644 --- a/wastebasket/WasteBasket.lua +++ b/wastebasket/WasteBasket.lua @@ -7,7 +7,8 @@ INSTALLATION (create directories if they donot exist): * Linux (current user): ~/.local/share/vlc/lua/extensions/ * Mac OS X (all users): /Applications/VLC.app/Contents/MacOS/share/lua/extensions/ - Restart VLC. -- The extension can then be found in the menu View > Wastebasket. +- The extension can then be found in the menu: + View > Move current playing file into wastebasket ]]-- --[[ Extension description ]] diff --git a/ytv/ytv b/ytv/ytv index 69eeeb8..adbb115 100755 --- a/ytv/ytv +++ b/ytv/ytv @@ -69,13 +69,14 @@ $SIG{'CHLD'} = sub { exit; }; do { # Sleep until there are matching files sleep(1); - @new = grep { not $before{$_} or $before{$_} > -M $_ } <*>; + @new = (grep { -s $_ > 1000000 } + grep { not $before{$_} or $before{$_} > -M $_ } <*>); } until @new; while(@new) { # Mark as seen map { $before{$_} = -M $_ } @new; # Run VLC on the matching files - system("vlc",@new); + system("vlc", map { $a=$_; s/.part//; $a,$_ } @new); @new = grep { not $before{$_} or $before{$_} > -M $_ } <*>; }