From eb54a9232878e7e32af87b2ab335bbfb6e2e43cb Mon Sep 17 00:00:00 2001 From: quentin Date: Mon, 13 Oct 2014 02:38:07 +0200 Subject: [PATCH 1/3] Add Tcl/Tk interpreters to languages.yml for shebang detection --- lib/linguist/languages.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/lib/linguist/languages.yml b/lib/linguist/languages.yml index c85fe463..1ff84122 100644 --- a/lib/linguist/languages.yml +++ b/lib/linguist/languages.yml @@ -2307,6 +2307,9 @@ Tcl: - .tcl - .adp - .tm + interpreters: + - tclsh + - wish Tcsh: type: programming From baa3cba0fc6faa38c6822cb39e336715d0f95640 Mon Sep 17 00:00:00 2001 From: quentin Date: Mon, 13 Oct 2014 03:05:56 +0200 Subject: [PATCH 2/3] Add sample Tcl/Tk scripts to test Tcl/Tk shebang detection Scripts taken from: * starfield: http://wiki.tcl.tk/14140 * owh: http://wiki.tcl.tk/906 --- samples/Tcl/owh | 63 +++++++++++++++++++++++++++++++++++++++++++ samples/Tcl/starfield | 28 +++++++++++++++++++ 2 files changed, 91 insertions(+) create mode 100755 samples/Tcl/owh create mode 100755 samples/Tcl/starfield diff --git a/samples/Tcl/owh b/samples/Tcl/owh new file mode 100755 index 00000000..9354c704 --- /dev/null +++ b/samples/Tcl/owh @@ -0,0 +1,63 @@ +#!/usr/bin/env tclsh +# http://wiki.tcl.tk/906 + +if {[llength $argv] < 1} { + puts "usage: owh ?init? body ?exit? + performs body (in Tcl) for each line (\$0) from stdin + owh: Ousterhout - Welch - Hobbs, to name a few" + exit -1 +} + +proc awksplit {text {split default}} { + set no 0 + if {$split eq "default"} { + set t {} + foreach string [split $text] { + if {$string ne {}} { + lappend t $string + } + } + } else { + set t [list $text $split] + } + uplevel 1 [list set NF [llength $t]] + foreach i $t {uplevel 1 [list set [incr no] $i]} + uplevel 1 {set 0 {};trace variable 0 ru 0} +} +proc 0 {_name index op} { + switch $op { + r { + uplevel { + set 0 {} + for {set i 1} {$i <= $NF} {incr i} {lappend 0 [set $i]} + set 0 [join $0 $OFS] + } + } + u {rename 0 {} ;# leave no traces of the trace..} + } +} + +proc print s {if {[catch {puts $s}]} exit} ;# good for broken pipe + +set FS default +set OFS { } + +if {[llength $argv] > 1} { + eval [lindex $argv 0] + set _body [lindex $argv 1] ;# strip outer braces + set _exit [lindex $argv 2] +} else { + set _body [lindex $argv 0] ;# strip outer braces + set _exit {} +} + +set NR 1 +while 1 { + gets stdin line + if {[eof stdin]} break + awksplit $line $FS + eval $_body + incr NR +} +set res [eval $_exit] +if {[string length $res]} {puts $res} diff --git a/samples/Tcl/starfield b/samples/Tcl/starfield new file mode 100755 index 00000000..674ba779 --- /dev/null +++ b/samples/Tcl/starfield @@ -0,0 +1,28 @@ +#!/usr/bin/env wish +# http://wiki.tcl.tk/14140 + +proc stars'go {c factor} { + set w [winfo width $c] + set h [winfo height $c] + $c scale all [expr {$w/2}] [expr {$h/2}] $factor $factor + foreach item [$c find all] { + if {[llength [$c bbox $item]] == 0} {$c delete $item; continue} ;# (1) + foreach {x0 y0 x1 y1} [$c bbox $item] break + if {$x1<0 || $x0>$w || $y1<0 || $y0>$h} {$c delete $item} + } + time { + set x [expr {rand()*$w}] + set y [expr {rand()*$h}] + set col [lpick {white yellow beige bisque cyan}] + $c create oval $x $y [expr {$x+1}] [expr {$y+1}] -fill $col \ + -outline $col + } 10 + after $::ms [info level 0] +} +proc lpick list {lindex $list [expr {int(rand()*[llength $list])}]} +#-- Let's go! +pack [canvas .c -bg black] -fill both -expand 1 +set ms 40 +bind . {incr ms -5} +bind . {incr ms 5} +stars'go .c 1.05 From 48f2949d6941b2f6fee6f1f99300288e8b08a627 Mon Sep 17 00:00:00 2001 From: quentin Date: Mon, 13 Oct 2014 10:09:07 +0200 Subject: [PATCH 3/3] Move the extension-less sample scripts in a filenames/ subdir --- samples/Tcl/{ => filenames}/owh | 0 samples/Tcl/{ => filenames}/starfield | 0 2 files changed, 0 insertions(+), 0 deletions(-) rename samples/Tcl/{ => filenames}/owh (100%) rename samples/Tcl/{ => filenames}/starfield (100%) diff --git a/samples/Tcl/owh b/samples/Tcl/filenames/owh similarity index 100% rename from samples/Tcl/owh rename to samples/Tcl/filenames/owh diff --git a/samples/Tcl/starfield b/samples/Tcl/filenames/starfield similarity index 100% rename from samples/Tcl/starfield rename to samples/Tcl/filenames/starfield