This file is indexed.

/usr/share/saods9/library/command.tcl is in saods9 7.5+repack1-2.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
#  Copyright (C) 1999-2016
#  Smithsonian Astrophysical Observatory, Cambridge, MA, USA
#  For conditions of distribution and use, see copyright notice in "copyright"

package provide DS9 1.0

proc BadVisualError {} {
    global ds9

    Error [msgcat::mc {Sorry, DS9 requires a Truecolor8, Truecolor16, Truecolor24 visual be available}]
    exit
}

proc ProcessCommandLineFirst {} {
    global argc
    global argv
    global icolorbar
    global ds9
    global pds9

    set i 0
    while {$i < $argc} {
	set item [lindex $argv $i]

	switch -- $item {
	    -help {
		puts "For more information, use --help"
		QuitDS9
	    }
	    -debug {incr i; ProcessDebugTclCmd argv i}
	    -private {
		# backward compatibility
	    }
	    -title {
		incr i
		set ds9(title) [lindex $argv $i]
		set t "SAOImage $ds9(title)"
		wm title $ds9(top) "$t"
		wm iconname $ds9(top) "$t"
	    }
	    -language {
		incr i
		set pds9(language) [lindex $argv $i]
		set pds9(language,name) [LanguageToName $pds9(language)]
	    }
	    -msg {
		incr i
		set pds9(language,dir) [lindex $argv $i]
	    }
	    -xpa {incr i; ProcessXPAFirstCmd argv i}
	}
	incr i
    }
}

proc ProcessCommandLine {} {
    global argc
    global argv

    ProcessCommand $argv $argc
}

proc ds9Cmd {argv} {
    ProcessCommand $argv [llength $argv]
}

proc ProcessCommand {argv argc} {
    global ds9
    global pds9
    global help
    global current
    global contour
    global colorbar
    global debug
    global wcs
    global view
    global grid
    global bin
    global scale
    global minmax
    global zscale
    global iis
    global file

    set file(type) fits
    set file(mode) {}
    set file(layer) {}
    set file(mosaic) wcs

    set load 0
    set noopts 0
    set i 0

    # Note: -help is processed previously for fv (temporary)
    set item {}

    while {$i < $argc} {
	set item [lindex $argv $i]
	switch -- $item {
	    -- {set noopts 1}
	    -? -
	    -help -
	    --help {HelpCommand}

	    -version {
		ProcessSendVersionCmd puts stdout {}
		QuitDS9
	    }

	    -2mass {incr i; Process2MASSCmd argv i}
	    -3d -
	    -3D {incr i; Process3DCmd argv i}
	    -about {ProcessSendAboutCmd puts stdout {} {} {}}
	    -align {incr i; ProcessAlignCmd argv i}
	    -analysis {incr i; ProcessAnalysisCmd argv i {} {}}
	    -array {set file(type) array}
	    -asinh {set scale(type) asinh; ChangeScale}
	    -bg -
	    -background {incr i; ProcessBgCmd argv i}
	    -backup {incr i; ProcessBackupCmd argv i}
	    -bin {incr i; ProcessBinCmd argv i}
	    -block {incr i; ProcessBlockCmd argv i}
	    -blink {incr i; ProcessBlinkCmd argv i}
	    -blue {set current(rgb) blue; RGBChannel}
	    -cat -
	    -catalog {incr i; ProcessCatalogCmd argv i}
	    -cd {incr i; ProcessCDCmd argv i}
	    -cmap {incr i; ProcessCmapCmd argv i}
	    -colorbar {incr i; ProcessColorbarCmd argv i}
	    -console {ProcessConsoleCmd argv i}
	    -contours -
	    -contour {incr i; ProcessContourCmd argv i}
	    -nocontour {set contour(view) 0; ContourUpdate}
	    -crop {incr i; ProcessCropCmd argv i}
	    -crosshair {incr i; ProcessCrosshairCmd argv i}
	    -cursor {incr i; ProcessCursorCmd argv i}
	    -datacube -
	    -cube {incr i; ProcessCubeCmd argv i}
	    -debug {incr i; ProcessDebugCmd argv i}
	    -dss -
	    -dsssao {incr i; ProcessSAOCmd argv i}
	    -dsseso {incr i; ProcessESOCmd argv i}
	    -dssstsci {incr i; ProcessSTSCICmd argv i}
	    -envi {set file(type) envi}
	    -export {incr i; ProcessExportCmd argv i}
	    -exit -
	    -quit {ProcessQuitCmd argv i}
	    -frame {incr i; ProcessFrameCmd argv i}
	    -fifo {
		incr i
		set fifo [lindex $argv $i]
		if {$fifo!="none"} {
		    set iis(ififo) ${fifo}i
		    set iis(ofifo) ${fifo}o
		} else {
		    set iis(ififo) none
		    set iis(ofifo) none
		}
	    }
	    -fifo_only {
		set iis(port) 0
		set iis(unix) none
	    }
	    -file -
	    -fits {set file(type) fits; CommandFitsCmd argv i}
	    -geometry {
		# already processed
	    }
	    -gif {set file(type) gif}
	    -green {set current(rgb) green; RGBChannel}
	    -grid {incr i; ProcessGridCmd argv i}
	    -nogrid {set grid(view) 0; GridUpdateCurrent}
	    -header {incr i; ProcessHeaderCmd argv i}
	    -height {incr i; ProcessHeightCmd argv i}
	    -histequ {set scale(type) histequ; ChangeScale}
	    -horzgraph {
		# backward compatibility
		set view(graph,horz) 1
		UpdateView
	    }
	    -nohorzgraph {
		# backward compatibility
		set view(graph,horz) 0
		UpdateView
	    }
	    -iconify {incr i; ProcessIconifyCmd argv i}
	    -iis {incr i; ProcessIISCmd argv i}
	    -info {
		# backward compatibility
		set view(info) 1
		UpdateView
	    }
	    -noinfo {
		# backward compatibility
		set view(info) 0
		UpdateView
	    }
	    -invert {set colorbar(invert) 1; InvertColorbar}
	    -jpg -
	    -jpeg {set file(type) jpeg}
	    -language {
		# already processed
		incr i
	    }
	    -lock {incr i; ProcessLockCmd argv i}
	    -linear {set scale(type) linear; ChangeScale}
	    -log {set scale(type) log; ChangeScale}
	    -lower {ProcessLowerCmd argv i}
	    -magnifier {incr i; ProcessMagnifierCmd argv i}
	    -nomagnifier {
		# backward compatibility
		set view(magnifier) 0
		UpdateView
	    }
	    -mask {incr i; set file(layer) [ProcessMaskCmd argv i]}
	    -nomask {set file(layer) {}}
	    -match {incr i; ProcessMatchCmd argv i}
	    -mecube {set file(type) mecube}
	    -memf -
	    -multiframe {set file(type) multiframe}
	    -minmax {incr i; ProcessMinMaxCmd argv i}
	    -minmaxmode {
		# backward compatibility
		incr i
		set minmax(mode) [lindex $argv $i]
	    }
	    -minmaxsample {
		# backward compatibility
		incr i
		set minmax(sample) [lindex $argv $i]
	    }
	    -mode {incr i; ProcessModeCmd argv i}

	    -mosaic {
		set file(type) mosaic
		CommandMosaicCmd argv i
	    }
	    -mosaicimage {
		set file(type) mosaicimage
		CommandMosaicImageCmd argv i
	    }

	    -mosaicimageiraf {
		# backward compatibility
		set file(type) mosaicimage
		set file(mosaic) iraf
	    }
	    -mosaicimagewcs {
		# backward compatibility
		set file(type) mosaicimage
		set file(mosaic) wcs
	    }
	    -mosaicimagewfpc2 {
		# backward compatibility
		set file(type) mosaicimage
		set file(mosaic) wfpc2
	    }

	    -mosaiciraf {
		# backward compatibility
		set file(type) mosaic
		set file(mosaic) iraf
	    }
	    -mosaicwcs {
		# backward compatibility
		set file(type) mosaic
		set file(mosaic) wcs
	    }
	    -savempeg -
	    -movie {incr i; ProcessMovieCmd argv i}

	    -msg {
		# already processed
		incr i
	    }
	    -nameserver {incr i; ProcessNRESCmd argv i}
	    -nan {incr i; ProcessNanCmd argv i}
	    -nrrd {set file(type) nrrd}
	    -nvss {incr i; ProcessNVSSCmd argv i}
	    -orient {incr i; ProcessOrientCmd argv i}
	    -pagesetup {incr i; ProcessPageSetupCmd argv i}
	    -pspagesetup {incr i; ProcessPSPageSetupCmd argv i}
	    -pan {incr i; ProcessPanCmd argv i}
	    -panner {
		# backward compatibility
		set view(panner) 1
		UpdateView
	    }
	    -nopanner {
		# backward compatibility
		set view(panner) 0
		UpdateView
	    }
	    -photo {
		# backward compatibility
		set file(type) tiff
	    }
	    -pixeltable {incr i; ProcessPixelTableCmd argv i}
	    -nopixeltable {PixelTableDestroyDialog}
	    -plot {incr i; ProcessPlotCmd argv i {} {}}
	    -png {set file(type) png}
	    -port {incr i; set iis(port) [lindex $argv $i]}
	    -inet_only -
	    -port_only {
		set iis(ififo) none
		set iis(ofifo) none
		set iis(unix) none
	    }
	    -pow {set scale(type) pow; ChangeScale}
	    -prefs {incr i; ProcessPrefsCmd argv i}
	    -preserve {incr i; ProcessPreserveCmd argv i}
	    -print {incr i; ProcessPrintCmd argv i}
	    -psprint {incr i; ProcessPSPrintCmd argv i}
	    -private {
		#already processed
	    }
	    -raise {ProcessRaiseCmd argv i}
	    -red {set current(rgb) red; RGBChannel}
	    -region -
	    -regions -
	    -regionfile {incr i; ProcessRegionsCmd argv i {} {}}
	    -restore {incr i; ProcessRestoreCmd argv i}
	    -rgb {incr i; ProcessRGBCmd argv i}
	    -rgbcube {set file(type) rgbcube}
	    -srgbcube {
		# backward compatibility
		set file(type) srgbcube
	    }
	    -rgbimage {set file(type) rgbimage}
	    -rgbarray {set file(type) rgbarray}
	    -rotate {incr i; ProcessRotateCmd argv i}
	    -samp {incr i; ProcessSAMPCmd argv i}
	    -savefits -
	    -save {incr i; ProcessSaveCmd argv i}
	    -saveimage {incr i; ProcessSaveImageCmd argv i}
	    -scale -
	    -ztrans {incr i; ProcessScaleCmd argv i}
	    -scalelims -
	    -scalelimits {
		#backward compatibility
		incr i
		set scale(min) [lindex $argv $i]
		incr i
		set scale(max) [lindex $argv $i]
		ChangeScaleLimit
	    }
	    -scalemode {
		#backward compatibility
		incr i
		set scale(mode) [string tolower [lindex $argv $i]]
		ChangeScaleMode
	    }
	    -scalescope {
		#backward compatibility
		incr i
		set scale(scope) [string tolower [lindex $argv $i]]
		ChangeScaleScope
	    }
	    -sfits {
		# backward compatibility
		set file(type) sfits
		CommandSFitsCmd argv i
	    }
	    -sia {incr i; ProcessSIACmd argv i}
	    -shm {incr i; ProcessShmCmd argv i 1}
	    -single {ProcessSingleCmd argv i}
	    -sinh {set scale(type) sinh; ChangeScale}
	    -skyview {incr i; ProcessSkyViewCmd argv i}
	    -sleep {incr i; ProcessSleepCmd argv i}
	    -slice {set file(mode) slice}
	    -noslice {set file(mode) {}}
	    -smooth {incr i; ProcessSmoothCmd argv i}
	    -smosaic {
		# backward compatibility
		set file(type) smosaic
		CommandMosaicCmd argv i
	    }
	    -smosaiciraf {
		# backward compatibility
		set file(type) smosaic
		set file(mosaic) iraf
	    }
	    -smosaicwcs {
		# backward compatibility
		set file(type) smosaic
		set file(mosaic) wcs
	    }
	    -squared {set scale(type) squared; ChangeScale}
	    -sqrt {set scale(type) sqrt; ChangeScale}
	    -source {incr i; ProcessSourceCmd argv i}
	    -tcl {incr i; ; ProcessTclCmd argv i {} {}}
	    -theme {
		# backward compatibility
		incr i; ProcessThemeCmd argv i
	    }
	    -threads {incr i; ProcessThreadsCmd argv i}
	    -tif -
	    -tiff {set file(type) tiff}
	    -tile {incr i; ProcessTileCmd argv i}
	    -title {
		#already processed
		incr i
	    }
	    -unix {incr i; set iis(unix) [lindex $argv $i]}
	    -unix_only {
		set iis(ififo) none
		set iis(ofifo) none
		set iis(port) 0
	    }
	    -url {set file(type) url}
	    -update {incr i; ProcessUpdateCmd argv i}
	    -vertgraph {
		#backward compatibility
		set view(graph,vert) 1
		UpdateView
	    }
	    -novertgraph {
		#backward compatibility
		set view(graph,vert) 0
		UpdateView
	    }
	    -view {incr i; ProcessViewCmd argv i}
	    -visual {
		#already processed
	    }
	    -vla -
	    -first {incr i; ProcessVLACmd argv i}
	    -vlss  {incr i; ProcessVLSSCmd argv i}
	    -vo {incr i; ProcessVOCmd argv i}
	    -wcs {incr i; ProcessWCSCmd argv i {} {}}
	    -wcsformat {
		#backward compatibility
		incr i
		set wcs(format,) [lindex $argv $i]
	    }
	    -web {incr i; ProcessWebCmd argv i}
	    -width {incr i; ProcessWidthCmd argv i}
	    -xpa {incr i; ProcessXPACmd argv i}
	    -z1 {
		#backward compatibility
		incr i
		set scale(min) [lindex $argv $i]
		ChangeScaleLimit
	    }
	    -z2 {
		#backward compatibility
		incr i
		set scale(max) [lindex $argv $i]
		ChangeScaleLimit
	    }
	    -zscale {incr i; ProcessZScaleCmd argv i}
	    -zmax {set scale(mode) zmax; ChangeScaleMode}
	    -zoom {incr i; ProcessZoomCmd argv i}

	    default {
		# allow abc, -, and -[foo] but not -abc
		if {!$noopts && [regexp -- {^-[a-zA-Z]+} $item]} {
		    puts stderr "[msgcat::mc {Unknown command}]: $item"
		    puts stderr "[msgcat::mc {For more information, use --help}]"
		    return
		}

		if {$load == 0} {
		    StartLoad
		    incr load
		}

		switch $ds9(wm) {
		    x11 -
		    aqua {CommandLineLoad $item argv i}
		    win32 {
			# if win32 and envoked via DOS shell
			# we must expand wildcards ourselves
			if {[catch {glob $item} fns]} {
			    # cygwin/double click/DOS Shell no wildcards
			    CommandLineLoad $item argv i
			} else {
			    # DOS Shell with wildcards
			    foreach fn $fns {
				CommandLineLoad $fn argv i
			    }
			}
		    }
		}

		FinishLoadPre
	    }
	}
	incr i
    }

    if {$load != 0} {
	FinishLoadPost
    }
}

proc CommandLineLoad {item argvname iname} {
    upvar $argvname argv
    upvar $iname i

    global file
    global current

    if {$current(frame) != {}} {
	switch -- [$current(frame) get type] {
	    base {CommandLineLoadBase $item $argvname $iname}
	    rgb {CommandLineLoadRGB $item $argvname $iname}
	    3d {CommandLineLoad3D $item $argvname $iname}
	}
    } else {
	CommandLineLoadBase $item $argvname $iname
    }

    SetFileLast $file(type) $item
}

proc CommandLineLoadBase {item argvname iname} {
    upvar 2 $argvname argv
    upvar 2 $iname i

    global file
    global ds9

    switch -- $file(type) {
	fits {
	    # under windows, a double click on a 
	    # data file comes here
	    MultiLoad $file(layer) $file(mode)
	    LoadFitsFile $item $file(layer) $file(mode)
	}
	url {
	    MultiLoad $file(layer) $file(mode)
	    LoadURLFits $item $file(layer) $file(mode)
	}


	rgbimage {
	    CreateRGBFrame
	    LoadRGBImageFile $item
	}
	rgbcube {
	    CreateRGBFrame
	    LoadRGBCubeFile $item
	}

	mecube {
	    MultiLoad
	    LoadMECubeFile $item
	}
	multiframe {
	    MultiLoad
	    LoadMultiFrameFile $item
	}

	mosaicimage {
	    MultiLoad $file(layer)
	    switch -- $file(mosaic) {
		iraf {LoadMosaicImageIRAFFile $item $file(layer)}
		wfpc2 {LoadMosaicImageWFPC2File $item}
		default {LoadMosaicImageWCSFile $item $file(layer) $file(mosaic)}
	    }
	}
	mosaic {
	    switch -- $file(mosaic) {
		iraf {LoadMosaicIRAFFile $item $file(layer)}
		default {LoadMosaicWCSFile $item $file(layer) $file(mosaic)}
	    }
	}

	sfits {
	    #backward compatibility
	    incr i
	    MultiLoad $file(layer) $file(mode)
	    LoadSFitsFile $item [lindex $argv $i] $file(layer) $file(mode)
	}
	srgbcube {
	    #backward compatibility
	    CreateRGBFrame
	    incr i
	    LoadSRGBCubeFile $item [lindex $argv $i]
	}
	smosaic {
	    #backward compatibility
	    incr i
	    switch -- $file(mosaic) {
		iraf {LoadSMosaicIRAFFile $item [lindex $argv $i] $file(layer)}
		default {LoadSMosaicWCSFile $item [lindex $argv $i] $file(layer) $file(mosaic)}
	    }
	}

	array {
	    MultiLoad $file(layer)
	    ImportArrayFile $item $file(layer)
	}
	rgbarray {
	    CreateRGBFrame
	    ImportRGBArrayFile $item
	}
	nrrd {
	    MultiLoad $file(layer)
	    ImportNRRDFile $item $file(layer)
	}
	envi {
	    MultiLoad
	    set fn $item
	    set fn2 [lindex $argv [expr $i+1]]
	    if {$fn2 == {} || [string range $fn2 0 0] == {-}} {
		set fn2 [FindENVIDataFile $fn]
	    } else {
		incr i
	    }
	    ImportENVIFile $fn $fn2
	}
	gif -
	tiff -
	jpeg -
	png {
	    MultiLoad {} $file(mode)
	    ImportPhotoFile $item $file(mode)
	}
    }
}

proc CommandLineLoadRGB {item argvname iname} {
    upvar 2 $argvname argv
    upvar 2 $iname i

    global file

    switch -- $file(type) {
	fits {LoadFitsFile $item {} $file(mode)}
	url {LoadURLFits $item {} $file(mode)}

	rgbimage {
	    MultiLoadRGB
	    LoadRGBImageFile $item
	}
	rgbcube {
	    MultiLoadRGB
	    LoadRGBCubeFile $item
	}

	mecube {LoadMECubeFile $item}
	multiframe {
	    # not supported
	}

	mosaicimage {
	    switch -- $file(mosaic) {
		iraf {LoadMosaicImageIRAFFile $item {}}
		wfpc2 {LoadMosaicImageWFPC2File $item}
		default {LoadMosaicImageWCSFile $item {} $file(mosaic)}
	    }
	}
	mosaic {
	    switch -- $file(mosaic) {
		iraf {LoadMosaicIRAFFile $item {}}
		default {LoadMosaicWCSFile $item {} $file(mosaic)}
	    }
	}

	sfits {
	    #backward compatibility
	    incr i
	    LoadSFitsFile $item [lindex $argv $i] {} $file(mode)
	}
	srgbcube {
	    #backward compatibility
	    MultiLoadRGB
	    incr i
	    LoadSRGBCubeFile $item [lindex $argv $i]
	}
	smosaic {
	    #backward compatibility
	    incr i
	    switch -- $file(mosaic) {
		iraf {LoadMosaicIRAFSFitsFile $item [lindex $argv $i] {}}
		default {LoadMosaicWCSSFitsFile $item [lindex $argv $i] {} $file(mosaic)}
	    }
	}

	array {ImportArrayFile $item {}}
	rgbarray {
	    MultiLoadRGB
	    ImportRGBArrayFile $item
	}
	nrrd {ImportNRRDFile $item {}}
	envi {}
	gif -
	tiff -
	jpeg -
	png {
	    MultiLoadRGB
	    ImportPhotoFile $item $file(mode)
	}

    }
}

proc CommandLineLoad3D {item argvname iname} {
    upvar 2 $argvname argv
    upvar 2 $iname i

    global file

    switch -- $file(type) {
	fits {
	    MultiLoad {} $file(mode)
	    LoadFitsFile $item {} $file(mode)
	}
	url {
	    MultiLoad {} $file(mode)
	    LoadURLFits $item {} $file(mode)
	}

	rgbimage {
	    CreateRGBFrame
	    LoadRGBImageFile $item
	}
	rgbcube {
	    CreateRGBFrame
	    LoadRGBCubeFile $item
	}

	mecube {
	    MultiLoad
	    LoadMECubeFile $item
	}
	multiframe {
	    MultiLoad
	    LoadMultiFrameFile $item
	}

	mosaicimage {
	    MultiLoad
	    switch -- $file(mosaic) {
		iraf {LoadMosaicImageIRAFFile $item {}}
		wfpc2 {LoadMosaicImageWFPC2File $item}
		default {LoadMosaicImageWCSFile $item {} $file(mosaic)}
	    }
	}
	mosaic {
	    switch -- $file(mosaic) {
		iraf {LoadMosaicIRAFFile $item {}}
		default {LoadMosaicWCSFile $item {} $file(mosaic)}
	    }
	}

	sfits {
	    #backward compatibility
	    incr i
	    MultiLoad {} $file(mode)
	    LoadSFitsFile $item [lindex $argv $i] {} $file(mode)
	}
	srgbcube {
	    #backward compatibility
	    CreateRGBFrame
	    incr i
	    LoadSRGBCubeFile $item [lindex $argv $i]
	}
	smosaic {
	    #backward compatibility
	    incr i
	    switch -- $file(mosaic) {
		iraf {LoadMosaicIRAFSFitsFile $item [lindex $argv $i] {}}
		default {LoadMosaicWCSSFitsFile $item [lindex $argv $i] {} $file(mosaic)}
	    }
	}

	array {
	    MultiLoad
	    ImportArrayFile $item {}
	}
	rgbarray {
	    CreateRGBFrame
	    ImportRGBArrayFile $item
	}
	nrrd {
	    MultiLoad
	    ImportNRRDFile $item {}
	}
	envi {
	    set fn $item
	    set fn2 [lindex $argv [expr $i+1]]
	    if {$fn2 == {} || [string range $fn2 0 0] == {-}} {
		set fn2 [FindENVIDataFile $fn]
	    } else {
		incr i
	    }
	    ImportENVIFile $fn $fn2
	}
	gif -
	tiff -
	jpeg -
	png {
	    MultiLoad {} $file(mode)
	    ImportPhotoFile $item $file(mode)
	}
    }
}

proc CommandFitsCmd {varname iname} {
    upvar $varname var
    upvar $iname i

    global file

    set item [string tolower [lindex $var [expr $i+1]]]
    switch -- $item {
	mosaicimage -
	mosaic {
	    set file(type) $item
	    incr i

	    set item [string tolower [lindex $var [expr $i+1]]]
	    switch -- $item {
		wfpc2 {incr i; set file(mosaic) wfpc2}
		default {CommandMosaicType $item $iname}
	    }
	}
	mecube -
	multiframe -
	rgbcube -
	rgbimage {
	    set file(type) $item
	    incr i
	}
    }
}

proc CommandSFitsCmd {varname iname} {
    upvar $varname var
    upvar $iname i

    global file

    set item [string tolower [lindex $var [expr $i+1]]]
    switch -- $item {
	mosaic {
	    set file(type) smosaic
	    incr i

	    set item [string tolower [lindex $var [expr $i+1]]]
	    switch -- $item {
		wfpc2 {incr i; set file(mosaic) wfpc2}
		default {CommandMosaicType $item $iname}
	    }
	}
	rgbcube {
	    set file(type) srgbcube
	    incr i
	}
    }
}

proc CommandMosaicImageCmd {varname iname} {
    upvar $varname var
    upvar $iname i

    global file

    set item [string tolower [lindex $var [expr $i+1]]]
    switch -- $item {
	wfpc2 {incr i; set file(mosaic) wfpc2}
	default {CommandMosaicType $item $iname}
    }
}

proc CommandMosaicCmd {varname iname} {
    upvar $varname var
    upvar $iname i

    global file

    set item [string tolower [lindex $var [expr $i+1]]]
    CommandMosaicType $item $iname
}

proc CommandMosaicType {sys iname} {
    upvar 2 $iname i

    global file

    switch $sys {
	iraf -
	wcs -
	wcsa -
	wcsb -
	wcsc -
	wcsd -
	wcse -
	wcsf -
	wcsg -
	wcsh -
	wcsi -
	wcsj -
	wcsk -
	wcsl -
	wcsm -
	wcsn -
	wcso -
	wcsp -
	wcsq -
	wcsr -
	wcss -
	wcst -
	wcsu -
	wcsv -
	wcsw -
	wcsx -
	wcsy -
	wcsz {
	    incr i
	    set file(mosaic) $sys
	}
	default {set file(mosaic) wcs}
    }
}