@@ -8,38 +8,38 @@ _term() {
88
99trap _term SIGTERM
1010
11+ # if there is a binder/ sub-directory it takes precedence
12+ # files outside it are ignored
1113# find binder sub-directory (if present)
12- for dir in " ./.binder" " ./binder" ; do
14+ binder_dir=" ./"
15+ for dir in " ./binder" " ./.binder" ; do
1316 if [ -e $dir ]; then
1417 binder_dir=$dir
18+ break
1519 fi
1620done
1721
18- # if there is a binder/ sub-directory it takes precedence
19- # files outside it are ignored
20- if [ -z $binder_dir ]; then
21- nixpath=" $binder_dir /default.nix" ;
22- if [ -f $binder_dir /start ]; then
23- chmod u+x $binder_dir /start
24- # Using `$@`` here which is what the internet recommends leads to
25- # errors when the command is something like `jupyter --ip=0.0.0.0 ...`
26- # as nix-shell picks that up as an argument to it instead of the command.
27- # There are several issues on the nix repos discussing this and adding support
28- # for -- to indicate "all arguments after this are for the command, not nix-shell"
29- # but it seems they have stalled/not yet produced an implementation.
30- # So let's use `$*` for now.
31- nix-shell $nixpath --command " $binder_dir /start $* " &
32- else
33- nix-shell $nixpath --command " $* " &
34- fi
22+ # raise error if both binder and .binder are found
23+ if [[ -d " ./binder" && -d " ./.binder" ]]; then
24+ echo " Error: Found both binder and .binder directories."
25+ exit 1
26+ fi
27+
28+ echo " binder_dir is: $binder_dir "
29+
30+ nixpath=" $binder_dir /default.nix" ;
31+ if [ -f $binder_dir /start ]; then
32+ chmod u+x $binder_dir /start
33+ # Using `$@`` here which is what the internet recommends leads to
34+ # errors when the command is something like `jupyter --ip=0.0.0.0 ...`
35+ # as nix-shell picks that up as an argument to it instead of the command.
36+ # There are several issues on the nix repos discussing this and adding support
37+ # for -- to indicate "all arguments after this are for the command, not nix-shell"
38+ # but it seems they have stalled/not yet produced an implementation.
39+ # So let's use `$*` for now.
40+ nix-shell $nixpath --command " $binder_dir /start $* " &
3541else
36- nixpath=" ./default.nix" ;
37- if [ -f ./start ]; then
38- chmod u+x ./start
39- nix-shell $nixpath --command " ./start $* " &
40- else
41- nix-shell $nixpath --command " $* " &
42- fi
42+ nix-shell $nixpath --command " $* " &
4343fi
4444
4545PID=$!
0 commit comments