189 "called at early startup to determine the kind of OS we are running on, |
189 "called at early startup to determine the kind of OS we are running on, |
190 and assigning a concrete subclass of me (remember: I am abstract) to the |
190 and assigning a concrete subclass of me (remember: I am abstract) to the |
191 global 'OperatingSystem'. |
191 global 'OperatingSystem'. |
192 Programs should never refer to any of my concrete classes directly, as |
192 Programs should never refer to any of my concrete classes directly, as |
193 they may not (will not) be present when ST/X is executed under anther OS." |
193 they may not (will not) be present when ST/X is executed under anther OS." |
194 |
194 |
195 |osType| |
195 |osType| |
196 |
196 |
197 osType := self getSystemType. |
197 osType := self getSystemType. |
198 osType = 'win32' ifTrue:[ |
198 osType = 'win32' ifTrue:[ |
199 ^ Win32OperatingSystem |
199 ^ Win32OperatingSystem |
200 ]. |
200 ]. |
201 osType = 'osx' ifTrue:[ |
201 osType = 'osx' ifTrue:[ |
202 ^ OSXOperatingSystem |
202 ^ OSXOperatingSystem |
203 ]. |
203 ]. |
204 osType = 'os2' ifTrue:[ |
204 osType = 'os2' ifTrue:[ |
205 ^ OS2OperatingSystem |
205 ^ OS2OperatingSystem |
206 ]. |
206 ]. |
207 osType = 'macos' ifTrue:[ |
207 osType = 'macos' ifTrue:[ |
208 ^ MacOperatingSystem |
208 ^ MacOperatingSystem |
209 ]. |
209 ]. |
210 ((osType = 'VMS') or:[osType = 'openVMS']) ifTrue:[ |
210 ((osType = 'VMS') or:[osType = 'openVMS']) ifTrue:[ |
211 ^ OpenVMSOperatingSystem |
211 ^ OpenVMSOperatingSystem |
212 ]. |
212 ]. |
213 ^ UnixOperatingSystem |
213 ^ UnixOperatingSystem |
214 ! |
214 ! |
215 |
215 |
216 initResources |
216 initResources |
621 |
621 |
622 openApplicationForDocument:aFilenameOrString operation:operationSymbol mimeType:mimeTypeStringArgOrNil |
622 openApplicationForDocument:aFilenameOrString operation:operationSymbol mimeType:mimeTypeStringArgOrNil |
623 "open a windows-shell/mac finder/desktop application to present the document contained in aFilenameOrString. |
623 "open a windows-shell/mac finder/desktop application to present the document contained in aFilenameOrString. |
624 This is typically used to present help-files, html documents, pdf documents etc. |
624 This is typically used to present help-files, html documents, pdf documents etc. |
625 operationSymbol is one of: |
625 operationSymbol is one of: |
626 open |
626 open |
627 edit |
627 edit |
628 explore |
628 explore |
629 mimeTypeStringArgOrNil is e.g. 'text/html' or: 'application/pdf'. |
629 mimeTypeStringArgOrNil is e.g. 'text/html' or: 'application/pdf'. |
630 If nil is passed in, the file's suffix is used to guess the mime type. |
630 If nil is passed in, the file's suffix is used to guess the mime type. |
631 " |
631 " |
632 |
632 |
633 self |
633 self |
634 openApplicationForDocument:aFilenameOrString |
634 openApplicationForDocument:aFilenameOrString |
635 operation:operationSymbol |
635 operation:operationSymbol |
636 mimeType:mimeTypeStringArgOrNil |
636 mimeType:mimeTypeStringArgOrNil |
637 inDirectory:nil |
637 inDirectory:nil |
638 ifNone:[ |
638 ifNone:[ |
639 "/ last resort: use a fileBrowser |
639 "/ last resort: use a fileBrowser |
640 UserPreferences fileBrowserClass openOn:aFilenameOrString |
640 UserPreferences fileBrowserClass openOn:aFilenameOrString |
641 ]. |
641 ]. |
642 |
642 |
643 " |
643 " |
644 self openApplicationForDocument: Filename currentDirectory operation:#open |
644 self openApplicationForDocument: Filename currentDirectory operation:#open |
645 self openApplicationForDocument: '..\..\doc\books\ArtOfSmalltalk\artMissing186187Fix1.pdf' asFilename operation:#open |
645 self openApplicationForDocument: '..\..\doc\books\ArtOfSmalltalk\artMissing186187Fix1.pdf' asFilename operation:#open |
646 |
646 |
654 |
654 |
655 openApplicationForDocument:aFilenameOrString operation:operationSymbol mimeType:mimeTypeStringArgOrNil ifNone:exceptionBlock |
655 openApplicationForDocument:aFilenameOrString operation:operationSymbol mimeType:mimeTypeStringArgOrNil ifNone:exceptionBlock |
656 "open a windows-shell/mac finder/desktop application to present the document contained in aFilenameOrString. |
656 "open a windows-shell/mac finder/desktop application to present the document contained in aFilenameOrString. |
657 This is typically used to present help-files, html documents, pdf documents etc. |
657 This is typically used to present help-files, html documents, pdf documents etc. |
658 operationSymbol is one of: |
658 operationSymbol is one of: |
659 open |
659 open |
660 edit |
660 edit |
661 explore |
661 explore |
662 mimeTypeStringArgOrNil is e.g. 'text/html' or: 'application/pdf'; |
662 mimeTypeStringArgOrNil is e.g. 'text/html' or: 'application/pdf'; |
663 if nil is passed in, the file's suffix is used to guess it. |
663 if nil is passed in, the file's suffix is used to guess it. |
664 " |
664 " |
665 |
665 |
666 ^ self |
666 ^ self |
667 openApplicationForDocument:aFilenameOrString operation:operationSymbol mimeType:mimeTypeStringArgOrNil |
667 openApplicationForDocument:aFilenameOrString operation:operationSymbol mimeType:mimeTypeStringArgOrNil |
668 inDirectory:nil ifNone:exceptionBlock |
668 inDirectory:nil ifNone:exceptionBlock |
669 ! |
669 ! |
670 |
670 |
671 openApplicationForDocument:aFilenameOrString operation:operationSymbol mimeType:mimeTypeStringArgOrNil |
671 openApplicationForDocument:aFilenameOrString operation:operationSymbol mimeType:mimeTypeStringArgOrNil |
672 inDirectory:directoryStringOrFilenameOrNil |
672 inDirectory:directoryStringOrFilenameOrNil |
673 "open a windows-shell/mac finder/desktop application to present the document contained in aFilenameOrString. |
673 "open a windows-shell/mac finder/desktop application to present the document contained in aFilenameOrString. |
674 This is typically used to present help-files, html documents, pdf documents etc. |
674 This is typically used to present help-files, html documents, pdf documents etc. |
675 operationSymbol is one of: |
675 operationSymbol is one of: |
676 open |
676 open |
677 edit |
677 edit |
678 explore |
678 explore |
679 mimeTypeStringArgOrNil is e.g. 'text/html' or: 'application/pdf'; |
679 mimeTypeStringArgOrNil is e.g. 'text/html' or: 'application/pdf'; |
680 if nil is passed in, the file's suffix is used to guess it. |
680 if nil is passed in, the file's suffix is used to guess it. |
681 " |
681 " |
682 |
682 |
683 |openCommand mimeTypeString| |
683 |openCommand mimeTypeString| |
684 |
684 |
685 mimeTypeString := mimeTypeStringArgOrNil. |
685 mimeTypeString := mimeTypeStringArgOrNil. |
686 |
686 |
687 MIMETypes notNil ifTrue:[ |
687 MIMETypes notNil ifTrue:[ |
688 mimeTypeString isNil ifTrue:[ |
688 mimeTypeString isNil ifTrue:[ |
689 mimeTypeString := MIMETypes mimeTypeForFilename:aFilenameOrString. |
689 mimeTypeString := MIMETypes mimeTypeForFilename:aFilenameOrString. |
690 ]. |
690 ]. |
691 mimeTypeString notNil ifTrue:[ |
691 mimeTypeString notNil ifTrue:[ |
692 openCommand := MIMETypes defaultCommandTemplateToOpenMimeType:mimeTypeString. |
692 openCommand := MIMETypes defaultCommandTemplateToOpenMimeType:mimeTypeString. |
693 ]. |
693 ]. |
694 ]. |
694 ]. |
695 openCommand notEmptyOrNil ifTrue:[ |
695 openCommand notEmptyOrNil ifTrue:[ |
696 (openCommand includesSubString:'%1') ifTrue:[ |
696 (openCommand includesSubString:'%1') ifTrue:[ |
697 openCommand := openCommand bindWith:aFilenameOrString asString. |
697 openCommand := openCommand bindWith:aFilenameOrString asString. |
698 ] ifFalse:[ |
698 ] ifFalse:[ |
699 openCommand := openCommand, ' "', aFilenameOrString asString, '"'. |
699 openCommand := openCommand, ' "', aFilenameOrString asString, '"'. |
700 ]. |
700 ]. |
701 |
701 |
702 (self |
702 (self |
703 startProcess:openCommand |
703 startProcess:openCommand |
704 inputFrom:nil outputTo:nil |
704 inputFrom:nil outputTo:nil |
705 errorTo:nil auxFrom:nil |
705 errorTo:nil auxFrom:nil |
706 environment:nil inDirectory:directoryStringOrFilenameOrNil) notNil |
706 environment:nil inDirectory:directoryStringOrFilenameOrNil) notNil |
707 ifTrue:[ |
707 ifTrue:[ |
708 ^ self. |
708 ^ self. |
709 ]. |
709 ]. |
710 ]. |
710 ]. |
711 ExecutionError raiseErrorString:'execution of command failed: ', openCommand. |
711 ExecutionError raiseErrorString:'execution of command failed: ', openCommand. |
712 |
712 |
713 " |
713 " |
714 self openApplicationForDocument: Filename currentDirectory operation:#open |
714 self openApplicationForDocument: Filename currentDirectory operation:#open |
719 |
719 |
720 "Created: / 29-10-2010 / 12:16:38 / cg" |
720 "Created: / 29-10-2010 / 12:16:38 / cg" |
721 "Modified: / 05-02-2011 / 16:13:42 / cg" |
721 "Modified: / 05-02-2011 / 16:13:42 / cg" |
722 ! |
722 ! |
723 |
723 |
724 openApplicationForDocument:aFilenameOrString operation:operationSymbol mimeType:mimeTypeStringArgOrNil |
724 openApplicationForDocument:aFilenameOrString operation:operationSymbol mimeType:mimeTypeStringArgOrNil |
725 inDirectory:directoryStringOrFilenameOrNil ifNone:exceptionBlock |
725 inDirectory:directoryStringOrFilenameOrNil ifNone:exceptionBlock |
726 "open a windows-shell/mac finder/desktop application to present the document contained in aFilenameOrString. |
726 "open a windows-shell/mac finder/desktop application to present the document contained in aFilenameOrString. |
727 This is typically used to present help-files, html documents, pdf documents etc. |
727 This is typically used to present help-files, html documents, pdf documents etc. |
728 operationSymbol is one of: |
728 operationSymbol is one of: |
729 open |
729 open |
730 edit |
730 edit |
731 explore |
731 explore |
732 mimeTypeStringArgOrNil is e.g. 'text/html' or: 'application/pdf'; |
732 mimeTypeStringArgOrNil is e.g. 'text/html' or: 'application/pdf'; |
733 if nil is passed in, the file's suffix is used to guess it. |
733 if nil is passed in, the file's suffix is used to guess it. |
734 " |
734 " |
735 |
735 |
736 [ |
736 [ |
737 ^ self |
737 ^ self |
738 openApplicationForDocument:aFilenameOrString |
738 openApplicationForDocument:aFilenameOrString |
739 operation:operationSymbol mimeType:mimeTypeStringArgOrNil |
739 operation:operationSymbol mimeType:mimeTypeStringArgOrNil |
740 inDirectory:directoryStringOrFilenameOrNil. |
740 inDirectory:directoryStringOrFilenameOrNil. |
741 ] on:ExecutionError do:[:ex| |
741 ] on:ExecutionError do:[:ex| |
742 exceptionBlock value. |
742 exceptionBlock value. |
743 ]. |
743 ]. |
744 ! ! |
744 ! ! |
745 |
745 |
746 !AbstractOperatingSystem class methodsFor:'error messages'! |
746 !AbstractOperatingSystem class methodsFor:'error messages'! |
747 |
747 |
953 |nullStream in out err shellAndArgs pid auxFd| |
953 |nullStream in out err shellAndArgs pid auxFd| |
954 |
954 |
955 aCommandString isNil ifTrue:[^ nil]. |
955 aCommandString isNil ifTrue:[^ nil]. |
956 |
956 |
957 (in := anExternalInStream) isNil ifTrue:[ |
957 (in := anExternalInStream) isNil ifTrue:[ |
958 nullStream := Filename nullDevice readWriteStream. |
958 nullStream := Filename nullDevice readWriteStream. |
959 in := nullStream. |
959 in := nullStream. |
960 ]. |
960 ]. |
961 (out := anExternalOutStream) isNil ifTrue:[ |
961 (out := anExternalOutStream) isNil ifTrue:[ |
962 nullStream isNil ifTrue:[nullStream := Filename nullDevice writeStream]. |
962 nullStream isNil ifTrue:[nullStream := Filename nullDevice writeStream]. |
963 out := nullStream. |
963 out := nullStream. |
964 ]. |
964 ]. |
965 (err := anExternalErrStream) isNil ifTrue:[ |
965 (err := anExternalErrStream) isNil ifTrue:[ |
966 err := out |
966 err := out |
967 ]. |
967 ]. |
968 anAuxiliaryStream notNil ifTrue:[ |
968 anAuxiliaryStream notNil ifTrue:[ |
969 auxFd := anAuxiliaryStream fileHandle. |
969 auxFd := anAuxiliaryStream fileHandle. |
970 ]. |
970 ]. |
971 |
971 |
972 shellAndArgs := self commandAndArgsForOSCommand:aCommandString. |
972 shellAndArgs := self commandAndArgsForOSCommand:aCommandString. |
973 |
973 |
974 pid := self |
974 pid := self |
975 exec:(shellAndArgs at:1) |
975 exec:(shellAndArgs at:1) |
976 withArguments:(shellAndArgs at:2) |
976 withArguments:(shellAndArgs at:2) |
977 environment:anEvironmentDictionary |
977 environment:anEvironmentDictionary |
978 fileDescriptors:(Array with:in fileHandle |
978 fileDescriptors:(Array with:in fileHandle |
979 with:out fileHandle |
979 with:out fileHandle |
980 with:err fileHandle |
980 with:err fileHandle |
981 with:auxFd) |
981 with:auxFd) |
982 fork:true |
982 fork:true |
983 newPgrp:newPgrp |
983 newPgrp:newPgrp |
984 inDirectory:dir |
984 inDirectory:dir |
985 showWindow:(showWindowBooleanOrNil ? (shellAndArgs at:3)). |
985 showWindow:(showWindowBooleanOrNil ? (shellAndArgs at:3)). |
986 |
986 |
987 nullStream notNil ifTrue:[ |
987 nullStream notNil ifTrue:[ |
988 nullStream close. |
988 nullStream close. |
989 ]. |
989 ]. |
990 |
990 |
991 ^ pid |
991 ^ pid |
992 |
992 |
993 "blocking at current prio (i.e. only higher prio threads execute): |
993 "blocking at current prio (i.e. only higher prio threads execute): |
1410 Set lineWise to true, if both error and output is sent to the same stream |
1410 Set lineWise to true, if both error and output is sent to the same stream |
1411 and you don't want lines to be mangled. Set lineWise = false to |
1411 and you don't want lines to be mangled. Set lineWise = false to |
1412 avoid blocking on pipes. |
1412 avoid blocking on pipes. |
1413 |
1413 |
1414 Special for windows: |
1414 Special for windows: |
1415 you can control (have to - sigh) if a window should be shown for the command or not. |
1415 you can control (have to - sigh) if a window should be shown for the command or not. |
1416 This is the OS's H_SHOWWINDOW argument. |
1416 This is the OS's H_SHOWWINDOW argument. |
1417 If you pass nil as showWindow-argument, the OS's default is used for the particular |
1417 If you pass nil as showWindow-argument, the OS's default is used for the particular |
1418 command, which is correct most of the time: i.e. a notepad will open its window, other (non-UI) |
1418 command, which is correct most of the time: i.e. a notepad will open its window, other (non-UI) |
1419 executables will not. |
1419 executables will not. |
1420 However, some command-line executables show a window, even if they should not. |
1420 However, some command-line executables show a window, even if they should not. |
1421 (and also, there seems to be an inconsistency between windows7 and newer windows: in newer, |
1421 (and also, there seems to be an inconsistency between windows7 and newer windows: in newer, |
1422 a shell command opens a cmd-window, whereas in windows7 it did not) |
1422 a shell command opens a cmd-window, whereas in windows7 it did not) |
1423 In this case, pass an explicit false argument to suppress it. |
1423 In this case, pass an explicit false argument to suppress it. |
1424 This argument is ignored on Unix systems. |
1424 This argument is ignored on Unix systems. |
1425 See examples below." |
1425 See examples below." |
1426 |
1426 |
1427 |osProcess| |
1427 |osProcess| |
1428 |
1428 |
1429 osProcess := OSProcess new |
1429 osProcess := OSProcess new |
1430 command:aCommandStringOrArray; |
1430 command:aCommandStringOrArray; |
1431 inStream:anInStream; |
1431 inStream:anInStream; |
1432 outStream:anOutStream; |
1432 outStream:anOutStream; |
1433 errorStream:anErrStream; |
1433 errorStream:anErrStream; |
1434 auxStream:anAuxStream; |
1434 auxStream:anAuxStream; |
1435 environment:environmentDictionary; |
1435 environment:environmentDictionary; |
1436 directory:dirOrNil; |
1436 directory:dirOrNil; |
1437 lineWise:lineWise; |
1437 lineWise:lineWise; |
1438 showWindow:showWindowBooleanOrNil. |
1438 showWindow:showWindowBooleanOrNil. |
1439 |
1439 |
1440 osProcess execute ifFalse:[ |
1440 osProcess execute ifFalse:[ |
1441 aBlock value:osProcess exitStatus. |
1441 aBlock value:osProcess exitStatus. |
1442 ^ false. |
1442 ^ false. |
1443 ]. |
1443 ]. |
1444 ^ true. |
1444 ^ true. |
1445 ! |
1445 ! |
1446 |
1446 |
1447 executeCommand:aCommandStringOrArray inputFrom:anInStream outputTo:anOutStream |
1447 executeCommand:aCommandStringOrArray inputFrom:anInStream outputTo:anOutStream |
1448 errorTo:anErrStream auxFrom:anAuxStream environment:environmentDictionary |
1448 errorTo:anErrStream auxFrom:anAuxStream environment:environmentDictionary |
1449 inDirectory:dirOrNil lineWise:lineWise onError:aBlock |
1449 inDirectory:dirOrNil lineWise:lineWise onError:aBlock |
1466 Set lineWise to true, if both error and output is sent to the same stream |
1466 Set lineWise to true, if both error and output is sent to the same stream |
1467 and you don't want lines to be mangled. Set lineWise = false to |
1467 and you don't want lines to be mangled. Set lineWise = false to |
1468 avoid blocking on pipes" |
1468 avoid blocking on pipes" |
1469 |
1469 |
1470 ^ self |
1470 ^ self |
1471 executeCommand:aCommandStringOrArray inputFrom:anInStream outputTo:anOutStream |
1471 executeCommand:aCommandStringOrArray inputFrom:anInStream outputTo:anOutStream |
1472 errorTo:anErrStream auxFrom:anAuxStream environment:environmentDictionary |
1472 errorTo:anErrStream auxFrom:anAuxStream environment:environmentDictionary |
1473 inDirectory:dirOrNil lineWise:lineWise showWindow:false onError:aBlock |
1473 inDirectory:dirOrNil lineWise:lineWise showWindow:false onError:aBlock |
1474 |
1474 |
1475 " |
1475 " |
1476 |outStream errStream| |
1476 |outStream errStream| |
1477 |
1477 |
1478 outStream := '' writeStream. |
1478 outStream := '' writeStream. |
1479 |
1479 |
1480 OperatingSystem executeCommand:'ls -l' |
1480 OperatingSystem executeCommand:'ls -l' |
1481 inputFrom:'abc' readStream |
1481 inputFrom:'abc' readStream |
1482 outputTo:outStream |
1482 outputTo:outStream |
1483 errorTo:nil |
1483 errorTo:nil |
1484 inDirectory:nil |
1484 inDirectory:nil |
1485 lineWise:true |
1485 lineWise:true |
1486 onError:[:exitStatus | ^ false]. |
1486 onError:[:exitStatus | ^ false]. |
1487 outStream contents |
1487 outStream contents |
1488 " |
1488 " |
1489 |
1489 |
1490 " |
1490 " |
1491 |outStream errStream| |
1491 |outStream errStream| |
1492 |
1492 |
1493 outStream := #[] writeStream. |
1493 outStream := #[] writeStream. |
1494 |
1494 |
1495 OperatingSystem executeCommand:'cat' |
1495 OperatingSystem executeCommand:'cat' |
1496 inputFrom:(ByteArray new:5000000) readStream |
1496 inputFrom:(ByteArray new:5000000) readStream |
1497 outputTo:outStream |
1497 outputTo:outStream |
1498 errorTo:nil |
1498 errorTo:nil |
1499 inDirectory:nil |
1499 inDirectory:nil |
1500 lineWise:false |
1500 lineWise:false |
1501 onError:[:exitStatus | ^ false]. |
1501 onError:[:exitStatus | ^ false]. |
1502 outStream size |
1502 outStream size |
1503 " |
1503 " |
1504 |
1504 |
1505 " |
1505 " |
1506 |outStream errStream| |
1506 |outStream errStream| |
1507 |
1507 |
1508 outStream := '' writeStream. |
1508 outStream := '' writeStream. |
1509 |
1509 |
1510 OperatingSystem executeCommand:'gpg -s --batch --no-tty --passphrase-fd 0 /tmp/passwd' |
1510 OperatingSystem executeCommand:'gpg -s --batch --no-tty --passphrase-fd 0 /tmp/passwd' |
1511 inputFrom:'bla' readStream |
1511 inputFrom:'bla' readStream |
1512 outputTo:outStream |
1512 outputTo:outStream |
1513 errorTo:nil |
1513 errorTo:nil |
1514 inDirectory:nil |
1514 inDirectory:nil |
1515 lineWise:true |
1515 lineWise:true |
1516 onError:[:exitStatus | false]. |
1516 onError:[:exitStatus | false]. |
1517 outStream contents |
1517 outStream contents |
1518 " |
1518 " |
1519 |
1519 |
1520 "Modified: / 11-02-2007 / 20:54:39 / cg" |
1520 "Modified: / 11-02-2007 / 20:54:39 / cg" |
1521 ! |
1521 ! |
1522 |
1522 |
1542 Set lineWise to true, if both error and output is sent to the same stream |
1542 Set lineWise to true, if both error and output is sent to the same stream |
1543 and you don't want lines to be mangled. Set lineWise = false to |
1543 and you don't want lines to be mangled. Set lineWise = false to |
1544 avoid blocking on pipes. |
1544 avoid blocking on pipes. |
1545 |
1545 |
1546 Special for windows: |
1546 Special for windows: |
1547 you can control (have to - sigh) if a window should be shown for the command or not. |
1547 you can control (have to - sigh) if a window should be shown for the command or not. |
1548 This is the OS's H_SHOWWINDOW argument. |
1548 This is the OS's H_SHOWWINDOW argument. |
1549 If you pass nil as showWindow-argument, the OS's default is used for the particular |
1549 If you pass nil as showWindow-argument, the OS's default is used for the particular |
1550 command, which is correct most of the time: i.e. a notepad will open its window, other (non-UI) |
1550 command, which is correct most of the time: i.e. a notepad will open its window, other (non-UI) |
1551 executables will not. |
1551 executables will not. |
1552 However, some command-line executables show a window, even if they should not. |
1552 However, some command-line executables show a window, even if they should not. |
1553 (and also, there seems to be an inconsistency between windows7 and newer windows: in newer, |
1553 (and also, there seems to be an inconsistency between windows7 and newer windows: in newer, |
1554 a shell command opens a cmd-window, whereas in windows7 it did not) |
1554 a shell command opens a cmd-window, whereas in windows7 it did not) |
1555 In this case, pass an explicit false argument to suppress it. |
1555 In this case, pass an explicit false argument to suppress it. |
1556 This argument is ignored on Unix systems. |
1556 This argument is ignored on Unix systems. |
1557 See examples below." |
1557 See examples below." |
1558 |
1558 |
1559 ^ self |
1559 ^ self |
1560 executeCommand:aCommandStringOrArray inputFrom:anInStream outputTo:anOutStream |
1560 executeCommand:aCommandStringOrArray inputFrom:anInStream outputTo:anOutStream |
1561 errorTo:anErrStream auxFrom:anAuxStream environment:environmentDictionary |
1561 errorTo:anErrStream auxFrom:anAuxStream environment:environmentDictionary |
1562 inDirectory:dirOrNil lineWise:lineWise newPgrp:true showWindow:showWindowBooleanOrNil onError:aBlock |
1562 inDirectory:dirOrNil lineWise:lineWise newPgrp:true showWindow:showWindowBooleanOrNil onError:aBlock |
1563 |
1563 |
1564 " |
1564 " |
1565 |outStream errStream| |
1565 |outStream errStream| |
1566 |
1566 |
1567 outStream := '' writeStream. |
1567 outStream := '' writeStream. |
1568 |
1568 |
1569 OperatingSystem executeCommand:'ls -l' |
1569 OperatingSystem executeCommand:'ls -l' |
1570 inputFrom:'abc' readStream |
1570 inputFrom:'abc' readStream |
1571 outputTo:outStream |
1571 outputTo:outStream |
1572 errorTo:nil |
1572 errorTo:nil |
1573 inDirectory:nil |
1573 inDirectory:nil |
1574 lineWise:true |
1574 lineWise:true |
1575 onError:[:exitStatus | ^ false]. |
1575 onError:[:exitStatus | ^ false]. |
1576 outStream contents |
1576 outStream contents |
1577 " |
1577 " |
1578 |
1578 |
1579 " |
1579 " |
1580 |outStream errStream| |
1580 |outStream errStream| |
1581 |
1581 |
1582 outStream := #[] writeStream. |
1582 outStream := #[] writeStream. |
1583 |
1583 |
1584 OperatingSystem executeCommand:'cat' |
1584 OperatingSystem executeCommand:'cat' |
1585 inputFrom:(ByteArray new:5000000) readStream |
1585 inputFrom:(ByteArray new:5000000) readStream |
1586 outputTo:outStream |
1586 outputTo:outStream |
1587 errorTo:nil |
1587 errorTo:nil |
1588 inDirectory:nil |
1588 inDirectory:nil |
1589 lineWise:false |
1589 lineWise:false |
1590 onError:[:exitStatus | ^ false]. |
1590 onError:[:exitStatus | ^ false]. |
1591 outStream size |
1591 outStream size |
1592 " |
1592 " |
1593 |
1593 |
1594 " |
1594 " |
1595 |outStream errStream| |
1595 |outStream errStream| |
1596 |
1596 |
1597 outStream := '' writeStream. |
1597 outStream := '' writeStream. |
1598 |
1598 |
1599 OperatingSystem executeCommand:'gpg -s --batch --no-tty --passphrase-fd 0 /tmp/passwd' |
1599 OperatingSystem executeCommand:'gpg -s --batch --no-tty --passphrase-fd 0 /tmp/passwd' |
1600 inputFrom:'bla' readStream |
1600 inputFrom:'bla' readStream |
1601 outputTo:outStream |
1601 outputTo:outStream |
1602 errorTo:nil |
1602 errorTo:nil |
1603 inDirectory:nil |
1603 inDirectory:nil |
1604 lineWise:true |
1604 lineWise:true |
1605 onError:[:exitStatus | false]. |
1605 onError:[:exitStatus | false]. |
1606 outStream contents |
1606 outStream contents |
1607 " |
1607 " |
1608 |
1608 |
1609 "Modified: / 08-11-2016 / 21:33:00 / cg" |
1609 "Modified: / 08-11-2016 / 21:33:00 / cg" |
1610 ! |
1610 ! |
1611 |
1611 |
1713 Return true if successful, the value from aBlock if not. |
1713 Return true if successful, the value from aBlock if not. |
1714 If not successfull, aBlock is called with an OsProcessStatus |
1714 If not successfull, aBlock is called with an OsProcessStatus |
1715 (containing the exit status) as argument." |
1715 (containing the exit status) as argument." |
1716 |
1716 |
1717 ^ self |
1717 ^ self |
1718 executeCommand:aCommandString |
1718 executeCommand:aCommandString |
1719 inputFrom:anInStream |
1719 inputFrom:anInStream |
1720 outputTo:anOutStream |
1720 outputTo:anOutStream |
1721 errorTo:anErrStream |
1721 errorTo:anErrStream |
1722 auxFrom:nil |
1722 auxFrom:nil |
1723 environment:env |
1723 environment:env |
1724 inDirectory:nil |
1724 inDirectory:nil |
1725 lineWise:false |
1725 lineWise:false |
1726 showWindow:showWindow |
1726 showWindow:showWindow |
1727 onError:aBlock |
1727 onError:aBlock |
1728 |
1728 |
1729 " |
1729 " |
1730 OperatingSystem |
1730 OperatingSystem |
1731 executeCommand:'dir' |
1731 executeCommand:'dir' |
1732 inputFrom:nil |
1732 inputFrom:nil |
1733 outputTo:nil |
1733 outputTo:nil |
1734 errorTo:nil |
1734 errorTo:nil |
1735 onError:[:status | Transcript flash] |
1735 onError:[:status | Transcript flash] |
1736 |
1736 |
1737 OperatingSystem |
1737 OperatingSystem |
1738 executeCommand:'foo' |
1738 executeCommand:'foo' |
1739 inputFrom:nil |
1739 inputFrom:nil |
1740 outputTo:nil |
1740 outputTo:nil |
1741 errorTo:nil |
1741 errorTo:nil |
1742 onError:[:status | Transcript flash] |
1742 onError:[:status | Transcript flash] |
1743 " |
1743 " |
1744 " |
1744 " |
1745 |outStr errStr| |
1745 |outStr errStr| |
1746 |
1746 |
1747 outStr := '' writeStream. |
1747 outStr := '' writeStream. |
1748 errStr := '' writeStream. |
1748 errStr := '' writeStream. |
1749 OperatingSystem |
1749 OperatingSystem |
1750 executeCommand:'ls' |
1750 executeCommand:'ls' |
1751 inputFrom:nil |
1751 inputFrom:nil |
1752 outputTo:outStr |
1752 outputTo:outStr |
1753 errorTo:errStr |
1753 errorTo:errStr |
1754 onError:[:status | Transcript flash]. |
1754 onError:[:status | Transcript flash]. |
1755 Transcript show:'out:'; showCR:outStr contents. |
1755 Transcript show:'out:'; showCR:outStr contents. |
1756 Transcript show:'err:'; showCR:errStr contents. |
1756 Transcript show:'err:'; showCR:errStr contents. |
1757 " |
1757 " |
1758 " |
1758 " |
1759 |outStr errStr| |
1759 |outStr errStr| |
1760 |
1760 |
1761 outStr := '' writeStream. |
1761 outStr := '' writeStream. |
1762 errStr := '' writeStream. |
1762 errStr := '' writeStream. |
1763 OperatingSystem |
1763 OperatingSystem |
1764 executeCommand:'ls /fooBar' |
1764 executeCommand:'ls /fooBar' |
1765 inputFrom:nil |
1765 inputFrom:nil |
1766 outputTo:outStr |
1766 outputTo:outStr |
1767 errorTo:errStr |
1767 errorTo:errStr |
1768 onError:[:status | Transcript flash]. |
1768 onError:[:status | Transcript flash]. |
1769 Transcript show:'out:'; showCR:outStr contents. |
1769 Transcript show:'out:'; showCR:outStr contents. |
1770 Transcript show:'err:'; showCR:errStr contents. |
1770 Transcript show:'err:'; showCR:errStr contents. |
1771 " |
1771 " |
1772 |
1772 |
1773 "Modified: / 10.11.1998 / 20:51:39 / cg" |
1773 "Modified: / 10.11.1998 / 20:51:39 / cg" |
1774 ! |
1774 ! |
1775 |
1775 |
1844 those internal stream(s). |
1844 those internal stream(s). |
1845 Nil stream args will execute the command connected to ST/X's standard input, output or |
1845 Nil stream args will execute the command connected to ST/X's standard input, output or |
1846 error resp. - i.e. usually, i/o will be from/to the terminal" |
1846 error resp. - i.e. usually, i/o will be from/to the terminal" |
1847 |
1847 |
1848 ^ self |
1848 ^ self |
1849 executeCommand:aCommandString |
1849 executeCommand:aCommandString |
1850 inputFrom:anInStream |
1850 inputFrom:anInStream |
1851 outputTo:anOutStream |
1851 outputTo:anOutStream |
1852 errorTo:anErrStream |
1852 errorTo:anErrStream |
1853 auxFrom:nil |
1853 auxFrom:nil |
1854 environment:nil |
1854 environment:nil |
1855 inDirectory:dirOrNil |
1855 inDirectory:dirOrNil |
1856 lineWise:lineWise |
1856 lineWise:lineWise |
1857 showWindow:showWindow |
1857 showWindow:showWindow |
1858 onError:aBlock |
1858 onError:aBlock |
1859 ! |
1859 ! |
1860 |
1860 |
1861 executeCommand:aCommandString inputFrom:anInStream outputTo:anOutStream errorTo:anErrStream inDirectory:dirOrNil onError:aBlock |
1861 executeCommand:aCommandString inputFrom:anInStream outputTo:anOutStream errorTo:anErrStream inDirectory:dirOrNil onError:aBlock |
1862 "execute the unix command specified by the argument, aCommandString. |
1862 "execute the unix command specified by the argument, aCommandString. |
1863 If aCommandString is a String, the commandString is passed to a shell for execution |
1863 If aCommandString is a String, the commandString is passed to a shell for execution |
1938 Return true if successful, the value from aBlock if not. |
1938 Return true if successful, the value from aBlock if not. |
1939 If not successfull, aBlock is called with an OsProcessStatus |
1939 If not successfull, aBlock is called with an OsProcessStatus |
1940 (containing the exit status) as argument." |
1940 (containing the exit status) as argument." |
1941 |
1941 |
1942 ^ self |
1942 ^ self |
1943 executeCommand:aCommandString |
1943 executeCommand:aCommandString |
1944 inputFrom:anInStream |
1944 inputFrom:anInStream |
1945 outputTo:anOutStream |
1945 outputTo:anOutStream |
1946 errorTo:anErrStream |
1946 errorTo:anErrStream |
1947 auxFrom:nil |
1947 auxFrom:nil |
1948 environment:nil |
1948 environment:nil |
1949 inDirectory:dir |
1949 inDirectory:dir |
1950 lineWise:false |
1950 lineWise:false |
1951 showWindow:showWindow |
1951 showWindow:showWindow |
1952 onError:aBlock |
1952 onError:aBlock |
1953 |
1953 |
1954 " |
1954 " |
1955 OperatingSystem |
1955 OperatingSystem |
1956 executeCommand:'dir' |
1956 executeCommand:'dir' |
1957 inputFrom:nil |
1957 inputFrom:nil |
1958 outputTo:nil |
1958 outputTo:nil |
1959 errorTo:nil |
1959 errorTo:nil |
1960 onError:[:status | Transcript flash] |
1960 onError:[:status | Transcript flash] |
1961 |
1961 |
1962 OperatingSystem |
1962 OperatingSystem |
1963 executeCommand:'foo' |
1963 executeCommand:'foo' |
1964 inputFrom:nil |
1964 inputFrom:nil |
1965 outputTo:nil |
1965 outputTo:nil |
1966 errorTo:nil |
1966 errorTo:nil |
1967 onError:[:status | Transcript flash] |
1967 onError:[:status | Transcript flash] |
1968 " |
1968 " |
1969 " |
1969 " |
1970 |outStr errStr| |
1970 |outStr errStr| |
1971 |
1971 |
1972 outStr := '' writeStream. |
1972 outStr := '' writeStream. |
1973 errStr := '' writeStream. |
1973 errStr := '' writeStream. |
1974 OperatingSystem |
1974 OperatingSystem |
1975 executeCommand:'ls' |
1975 executeCommand:'ls' |
1976 inputFrom:nil |
1976 inputFrom:nil |
1977 outputTo:outStr |
1977 outputTo:outStr |
1978 errorTo:errStr |
1978 errorTo:errStr |
1979 onError:[:status | Transcript flash]. |
1979 onError:[:status | Transcript flash]. |
1980 Transcript show:'out:'; showCR:outStr contents. |
1980 Transcript show:'out:'; showCR:outStr contents. |
1981 Transcript show:'err:'; showCR:errStr contents. |
1981 Transcript show:'err:'; showCR:errStr contents. |
1982 " |
1982 " |
1983 " |
1983 " |
1984 |outStr errStr| |
1984 |outStr errStr| |
1985 |
1985 |
1986 outStr := '' writeStream. |
1986 outStr := '' writeStream. |
1987 errStr := '' writeStream. |
1987 errStr := '' writeStream. |
1988 OperatingSystem |
1988 OperatingSystem |
1989 executeCommand:'ls /fooBar' |
1989 executeCommand:'ls /fooBar' |
1990 inputFrom:nil |
1990 inputFrom:nil |
1991 outputTo:outStr |
1991 outputTo:outStr |
1992 errorTo:errStr |
1992 errorTo:errStr |
1993 onError:[:status | Transcript flash]. |
1993 onError:[:status | Transcript flash]. |
1994 Transcript show:'out:'; showCR:outStr contents. |
1994 Transcript show:'out:'; showCR:outStr contents. |
1995 Transcript show:'err:'; showCR:errStr contents. |
1995 Transcript show:'err:'; showCR:errStr contents. |
1996 " |
1996 " |
1997 |
1997 |
1998 "Modified: / 10.11.1998 / 20:51:39 / cg" |
1998 "Modified: / 10.11.1998 / 20:51:39 / cg" |
1999 ! |
1999 ! |
2000 |
2000 |
2075 Return true if successful, the value from aBlock if not. |
2075 Return true if successful, the value from aBlock if not. |
2076 If not successfull, aBlock is called with an OsProcessStatus |
2076 If not successfull, aBlock is called with an OsProcessStatus |
2077 (containing the exit status) as argument." |
2077 (containing the exit status) as argument." |
2078 |
2078 |
2079 ^ self |
2079 ^ self |
2080 executeCommand:aCommandString |
2080 executeCommand:aCommandString |
2081 inputFrom:anInStream |
2081 inputFrom:anInStream |
2082 outputTo:anOutStream |
2082 outputTo:anOutStream |
2083 errorTo:anErrStream |
2083 errorTo:anErrStream |
2084 auxFrom:nil |
2084 auxFrom:nil |
2085 environment:nil |
2085 environment:nil |
2086 inDirectory:nil |
2086 inDirectory:nil |
2087 lineWise:false |
2087 lineWise:false |
2088 showWindow:showWindow |
2088 showWindow:showWindow |
2089 onError:aBlock |
2089 onError:aBlock |
2090 |
2090 |
2091 " |
2091 " |
2092 OperatingSystem |
2092 OperatingSystem |
2093 executeCommand:'dir' |
2093 executeCommand:'dir' |
2094 inputFrom:nil |
2094 inputFrom:nil |
2095 outputTo:nil |
2095 outputTo:nil |
2096 errorTo:nil |
2096 errorTo:nil |
2097 onError:[:status | Transcript flash] |
2097 onError:[:status | Transcript flash] |
2098 |
2098 |
2099 OperatingSystem |
2099 OperatingSystem |
2100 executeCommand:'foo' |
2100 executeCommand:'foo' |
2101 inputFrom:nil |
2101 inputFrom:nil |
2102 outputTo:nil |
2102 outputTo:nil |
2103 errorTo:nil |
2103 errorTo:nil |
2104 onError:[:status | Transcript flash] |
2104 onError:[:status | Transcript flash] |
2105 " |
2105 " |
2106 " |
2106 " |
2107 |outStr errStr| |
2107 |outStr errStr| |
2108 |
2108 |
2109 outStr := '' writeStream. |
2109 outStr := '' writeStream. |
2110 errStr := '' writeStream. |
2110 errStr := '' writeStream. |
2111 OperatingSystem |
2111 OperatingSystem |
2112 executeCommand:'ls' |
2112 executeCommand:'ls' |
2113 inputFrom:nil |
2113 inputFrom:nil |
2114 outputTo:outStr |
2114 outputTo:outStr |
2115 errorTo:errStr |
2115 errorTo:errStr |
2116 onError:[:status | Transcript flash]. |
2116 onError:[:status | Transcript flash]. |
2117 Transcript show:'out:'; showCR:outStr contents. |
2117 Transcript show:'out:'; showCR:outStr contents. |
2118 Transcript show:'err:'; showCR:errStr contents. |
2118 Transcript show:'err:'; showCR:errStr contents. |
2119 " |
2119 " |
2120 " |
2120 " |
2121 |outStr errStr| |
2121 |outStr errStr| |
2122 |
2122 |
2123 outStr := '' writeStream. |
2123 outStr := '' writeStream. |
2124 errStr := '' writeStream. |
2124 errStr := '' writeStream. |
2125 OperatingSystem |
2125 OperatingSystem |
2126 executeCommand:'ls /fooBar' |
2126 executeCommand:'ls /fooBar' |
2127 inputFrom:nil |
2127 inputFrom:nil |
2128 outputTo:outStr |
2128 outputTo:outStr |
2129 errorTo:errStr |
2129 errorTo:errStr |
2130 onError:[:status | Transcript flash]. |
2130 onError:[:status | Transcript flash]. |
2131 Transcript show:'out:'; showCR:outStr contents. |
2131 Transcript show:'out:'; showCR:outStr contents. |
2132 Transcript show:'err:'; showCR:errStr contents. |
2132 Transcript show:'err:'; showCR:errStr contents. |
2133 " |
2133 " |
2134 |
2134 |
2135 "Modified: / 10.11.1998 / 20:51:39 / cg" |
2135 "Modified: / 10.11.1998 / 20:51:39 / cg" |
2136 ! |
2136 ! |
2137 |
2137 |
2275 "much like #executeCommand:, but changes the current directory |
2275 "much like #executeCommand:, but changes the current directory |
2276 for the command. Since this is OS specific, use this instead of |
2276 for the command. Since this is OS specific, use this instead of |
2277 hardwiring any 'cd ..' command strings into your applictions. |
2277 hardwiring any 'cd ..' command strings into your applictions. |
2278 |
2278 |
2279 Special for windows: |
2279 Special for windows: |
2280 you can control (have to - sigh) if a window should be shown for the command or not. |
2280 you can control (have to - sigh) if a window should be shown for the command or not. |
2281 This is the OS's H_SHOWWINDOW argument. |
2281 This is the OS's H_SHOWWINDOW argument. |
2282 If you pass nil as showWindow-argument, the OS's default is used for the particular |
2282 If you pass nil as showWindow-argument, the OS's default is used for the particular |
2283 command, which is correct most of the time: i.e. a notepad will open its window, other (non-UI) |
2283 command, which is correct most of the time: i.e. a notepad will open its window, other (non-UI) |
2284 executables will not. |
2284 executables will not. |
2285 However, some command-line executables show a window, even if they should not. |
2285 However, some command-line executables show a window, even if they should not. |
2286 (and also, there seems to be an inconsistency between windows7 and newer windows: in newer, |
2286 (and also, there seems to be an inconsistency between windows7 and newer windows: in newer, |
2287 a shell command opens a cmd-window, whereas in windows7 it did not) |
2287 a shell command opens a cmd-window, whereas in windows7 it did not) |
2288 In this case, pass an explicit false argument to suppress it. |
2288 In this case, pass an explicit false argument to suppress it. |
2289 This argument is ignored on Unix systems. |
2289 This argument is ignored on Unix systems. |
2290 See examples below." |
2290 See examples below." |
2291 |
2291 |
2292 ^ self |
2292 ^ self |
2293 executeCommand:aCommandString |
2293 executeCommand:aCommandString |
2294 inputFrom:nil |
2294 inputFrom:nil |
2295 outputTo:outStreamOrNil |
2295 outputTo:outStreamOrNil |
2296 errorTo:errStreamOrNil |
2296 errorTo:errStreamOrNil |
2297 auxFrom:nil |
2297 auxFrom:nil |
2298 environment:nil |
2298 environment:nil |
2299 inDirectory:aDirectory |
2299 inDirectory:aDirectory |
2300 lineWise:false |
2300 lineWise:false |
2301 newPgrp:true |
2301 newPgrp:true |
2302 showWindow:showWindowBooleanOrNil |
2302 showWindow:showWindowBooleanOrNil |
2303 onError:[:status| false] |
2303 onError:[:status| false] |
2304 |
2304 |
2305 " |
2305 " |
2306 OperatingSystem executeCommand:'tdump date.obj' inDirectory:'c:\winstx\stx\libbasic\objbc'. |
2306 OperatingSystem executeCommand:'tdump date.obj' inDirectory:'c:\winstx\stx\libbasic\objbc'. |
2307 OperatingSystem executeCommand:'xxdir date.obj' inDirectory:'c:\winstx\stx\libbasic\objbc'. |
2307 OperatingSystem executeCommand:'xxdir date.obj' inDirectory:'c:\winstx\stx\libbasic\objbc'. |
2308 OperatingSystem executeCommand:'dir' inDirectory:'c:\'. |
2308 OperatingSystem executeCommand:'dir' inDirectory:'c:\'. |
2344 executeCommand:aCommandString showWindow:aBooleanOrNil |
2344 executeCommand:aCommandString showWindow:aBooleanOrNil |
2345 "execute the OS command specified by the argument, aCommandString. |
2345 "execute the OS command specified by the argument, aCommandString. |
2346 If aCommandString is a String, the commandString is passed to a shell for execution |
2346 If aCommandString is a String, the commandString is passed to a shell for execution |
2347 - see the description of 'sh -c' in your UNIX manual ('cmd.com' in your MSDOS manual). |
2347 - see the description of 'sh -c' in your UNIX manual ('cmd.com' in your MSDOS manual). |
2348 If aCommandString is an Array, the first element is the command to be executed, |
2348 If aCommandString is an Array, the first element is the command to be executed, |
2349 and the other elements are the arguments to the command. |
2349 and the other elements are the arguments to the command. |
2350 No shell is invoked in this case. |
2350 No shell is invoked in this case. |
2351 This blocks the current thread until the command has finished. |
2351 This blocks the current thread until the command has finished. |
2352 Return true if successful, false otherwise. |
2352 Return true if successful, false otherwise. |
2353 |
2353 |
2354 Special for windows: |
2354 Special for windows: |
2355 you can control (have to - sigh) if a window should be shown for the command or not. |
2355 you can control (have to - sigh) if a window should be shown for the command or not. |
2356 This is the OS's H_SHOWWINDOW argument. |
2356 This is the OS's H_SHOWWINDOW argument. |
2357 If you pass nil as showWindow-argument, the OS's default is used for the particular |
2357 If you pass nil as showWindow-argument, the OS's default is used for the particular |
2358 command, which is correct most of the time: i.e. a notepad will open its window, other (non-UI) |
2358 command, which is correct most of the time: i.e. a notepad will open its window, other (non-UI) |
2359 executables will not. |
2359 executables will not. |
2360 However, some command-line executables show a window, even if they should not. |
2360 However, some command-line executables show a window, even if they should not. |
2361 (and also, there seems to be an inconsistency between windows7 and newer windows: in newer, |
2361 (and also, there seems to be an inconsistency between windows7 and newer windows: in newer, |
2362 a shell command opens a cmd-window, whereas in windows7 it did not) |
2362 a shell command opens a cmd-window, whereas in windows7 it did not) |
2363 In this case, pass an explicit false argument to suppress it. |
2363 In this case, pass an explicit false argument to suppress it. |
2364 This argument is ignored on Unix systems. |
2364 This argument is ignored on Unix systems. |
2365 See examples below. |
2365 See examples below. |
2366 " |
2366 " |
2367 |
2367 |
2368 ^ self |
2368 ^ self |
2369 executeCommand:aCommandString |
2369 executeCommand:aCommandString |
2370 inputFrom:nil |
2370 inputFrom:nil |
2371 outputTo:nil |
2371 outputTo:nil |
2372 errorTo:nil |
2372 errorTo:nil |
2373 auxFrom:nil |
2373 auxFrom:nil |
2374 environment:nil |
2374 environment:nil |
2375 inDirectory:nil |
2375 inDirectory:nil |
2376 lineWise:false |
2376 lineWise:false |
2377 showWindow:aBooleanOrNil |
2377 showWindow:aBooleanOrNil |
2378 onError:[:status| false] |
2378 onError:[:status| false] |
2379 |
2379 |
2380 "unix: |
2380 "unix: |
2381 |
2381 |
2382 OperatingSystem executeCommand:'sleep 30'. |
2382 OperatingSystem executeCommand:'sleep 30'. |
2383 OperatingSystem executeCommand:'pwd'. |
2383 OperatingSystem executeCommand:'pwd'. |
2594 If successful, this method does NOT return and smalltalk is gone. |
2594 If successful, this method does NOT return and smalltalk is gone. |
2595 If not successful, it does return. |
2595 If not successful, it does return. |
2596 Can be used on UNIX with fork or on other systems to chain to another program." |
2596 Can be used on UNIX with fork or on other systems to chain to another program." |
2597 |
2597 |
2598 ^ self |
2598 ^ self |
2599 exec:aCommandPath |
2599 exec:aCommandPath |
2600 withArguments:argArray |
2600 withArguments:argArray |
2601 environment:nil |
2601 environment:nil |
2602 fileDescriptors:#(0 1 2) |
2602 fileDescriptors:#(0 1 2) |
2603 fork:false |
2603 fork:false |
2604 newPgrp:false |
2604 newPgrp:false |
2605 inDirectory:nil |
2605 inDirectory:nil |
2606 showWindow:false |
2606 showWindow:false |
2607 |
2607 |
2608 "/ never reached ... |
2608 "/ never reached ... |
2609 |
2609 |
2610 "Modified: / 12.11.1998 / 14:44:26 / cg" |
2610 "Modified: / 12.11.1998 / 14:44:26 / cg" |
2611 ! |
2611 ! |
2612 |
2612 |
2613 exec:aCommandPath withArguments:argArray environment:env fileDescriptors:fds fork:doFork newPgrp:newGrp inDirectory:aDirectory |
2613 exec:aCommandPath withArguments:argArray environment:env fileDescriptors:fds fork:doFork newPgrp:newGrp inDirectory:aDirectory |
2614 <resource: #obsolete> |
2614 <resource: #obsolete> |
2615 "execute an OS command" |
2615 "execute an OS command" |
2616 |
2616 |
2617 ^ self |
2617 ^ self |
2618 exec:aCommandPath withArguments:argArray environment:env fileDescriptors:fds fork:doFork |
2618 exec:aCommandPath withArguments:argArray environment:env fileDescriptors:fds fork:doFork |
2619 newPgrp:newGrp inDirectory:aDirectory showWindow:false |
2619 newPgrp:newGrp inDirectory:aDirectory showWindow:false |
2620 |
2620 |
2621 "Created: / 12.11.1998 / 14:46:15 / cg" |
2621 "Created: / 12.11.1998 / 14:46:15 / cg" |
2622 ! |
2622 ! |
2623 |
2623 |
2624 exec:aCommandPath withArguments:argArray fileDescriptors:fileDescriptors fork:doFork newPgrp:newPgrp inDirectory:aDirectory |
2624 exec:aCommandPath withArguments:argArray fileDescriptors:fileDescriptors fork:doFork newPgrp:newPgrp inDirectory:aDirectory |
2625 <resource: #obsolete> |
2625 <resource: #obsolete> |
2626 ^ self |
2626 ^ self |
2627 exec:aCommandPath |
2627 exec:aCommandPath |
2628 withArguments:argArray |
2628 withArguments:argArray |
2629 environment:nil |
2629 environment:nil |
2630 fileDescriptors:fileDescriptors |
2630 fileDescriptors:fileDescriptors |
2631 fork:doFork |
2631 fork:doFork |
2632 newPgrp:newPgrp |
2632 newPgrp:newPgrp |
2633 inDirectory:aDirectory |
2633 inDirectory:aDirectory |
2634 showWindow:false |
2634 showWindow:false |
2635 ! |
2635 ! |
2636 |
2636 |
2637 exec:aCommandPath withArguments:argArray fork:doFork |
2637 exec:aCommandPath withArguments:argArray fork:doFork |
2638 <resource: #obsolete> |
2638 <resource: #obsolete> |
2639 "execute an OS command without I/O redirection. |
2639 "execute an OS command without I/O redirection. |
2640 The command reads its input and writes its output |
2640 The command reads its input and writes its output |
2641 from/to whatever terminal device ST/X was started |
2641 from/to whatever terminal device ST/X was started |
2642 (typically, the terminal window)" |
2642 (typically, the terminal window)" |
2643 |
2643 |
2644 ^ self |
2644 ^ self |
2645 exec:aCommandPath |
2645 exec:aCommandPath |
2646 withArguments:argArray |
2646 withArguments:argArray |
2647 environment:nil |
2647 environment:nil |
2648 fileDescriptors:#(0 1 2) |
2648 fileDescriptors:#(0 1 2) |
2649 fork:doFork |
2649 fork:doFork |
2650 newPgrp:false |
2650 newPgrp:false |
2651 inDirectory:nil |
2651 inDirectory:nil |
2652 showWindow:false |
2652 showWindow:false |
2653 " |
2653 " |
2654 |id| |
2654 |id| |
2655 |
2655 |
2656 id := OperatingSystem fork. |
2656 id := OperatingSystem fork. |
2657 id == 0 ifTrue:[ |
2657 id == 0 ifTrue:[ |
2658 'I am the child'. |
2658 'I am the child'. |
2659 OperatingSystem |
2659 OperatingSystem |
2660 exec:'/bin/ls' |
2660 exec:'/bin/ls' |
2661 withArguments:#('ls' '/tmp') |
2661 withArguments:#('ls' '/tmp') |
2662 fork:false. |
2662 fork:false. |
2663 'not reached'. |
2663 'not reached'. |
2664 ] |
2664 ] |
2665 " |
2665 " |
2666 |
2666 |
2667 " |
2667 " |
2668 |id| |
2668 |id| |
2669 |
2669 |
2670 id := OperatingSystem fork. |
2670 id := OperatingSystem fork. |
2671 id == 0 ifTrue:[ |
2671 id == 0 ifTrue:[ |
2672 'I am the child'. |
2672 'I am the child'. |
2673 OperatingSystem |
2673 OperatingSystem |
2674 exec:'/bin/sh' |
2674 exec:'/bin/sh' |
2675 withArguments:#('sh' '-c' 'sleep 2;echo 1;sleep 2;echo 2') |
2675 withArguments:#('sh' '-c' 'sleep 2;echo 1;sleep 2;echo 2') |
2676 fork:false. |
2676 fork:false. |
2677 'not reached'. |
2677 'not reached'. |
2678 ]. |
2678 ]. |
2679 id printNL. |
2679 id printNL. |
2680 (Delay forSeconds:3.5) wait. |
2680 (Delay forSeconds:3.5) wait. |
2681 'killing ...' printNL. |
2681 'killing ...' printNL. |
2682 OperatingSystem sendSignal:(OperatingSystem sigTERM) to:id. |
2682 OperatingSystem sendSignal:(OperatingSystem sigTERM) to:id. |
2693 The command reads its input and writes its output |
2693 The command reads its input and writes its output |
2694 from/to whatever terminal device ST/X was started |
2694 from/to whatever terminal device ST/X was started |
2695 (typically, the terminal window)" |
2695 (typically, the terminal window)" |
2696 |
2696 |
2697 ^ self |
2697 ^ self |
2698 exec:aCommandPath |
2698 exec:aCommandPath |
2699 withArguments:argArray |
2699 withArguments:argArray |
2700 environment:nil |
2700 environment:nil |
2701 fileDescriptors:#(0 1 2) |
2701 fileDescriptors:#(0 1 2) |
2702 fork:doFork |
2702 fork:doFork |
2703 newPgrp:false |
2703 newPgrp:false |
2704 inDirectory:aDirectory |
2704 inDirectory:aDirectory |
2705 showWindow:false |
2705 showWindow:false |
2706 " |
2706 " |
2707 |id| |
2707 |id| |
2708 |
2708 |
2709 id := OperatingSystem fork. |
2709 id := OperatingSystem fork. |
2710 id == 0 ifTrue:[ |
2710 id == 0 ifTrue:[ |
2711 'I am the child'. |
2711 'I am the child'. |
2712 OperatingSystem |
2712 OperatingSystem |
2713 exec:'/bin/ls' |
2713 exec:'/bin/ls' |
2714 withArguments:#('ls' '/tmp') |
2714 withArguments:#('ls' '/tmp') |
2715 fork:false. |
2715 fork:false. |
2716 'not reached'. |
2716 'not reached'. |
2717 ] |
2717 ] |
2718 " |
2718 " |
2719 |
2719 |
2720 " |
2720 " |
2721 |id| |
2721 |id| |
2722 |
2722 |
2723 id := OperatingSystem fork. |
2723 id := OperatingSystem fork. |
2724 id == 0 ifTrue:[ |
2724 id == 0 ifTrue:[ |
2725 'I am the child'. |
2725 'I am the child'. |
2726 OperatingSystem |
2726 OperatingSystem |
2727 exec:'/bin/sh' |
2727 exec:'/bin/sh' |
2728 withArguments:#('sh' '-c' 'sleep 2;echo 1;sleep 2;echo 2') |
2728 withArguments:#('sh' '-c' 'sleep 2;echo 1;sleep 2;echo 2') |
2729 fork:false. |
2729 fork:false. |
2730 'not reached'. |
2730 'not reached'. |
2731 ]. |
2731 ]. |
2732 id printNL. |
2732 id printNL. |
2733 (Delay forSeconds:3.5) wait. |
2733 (Delay forSeconds:3.5) wait. |
2734 'killing ...' printNL. |
2734 'killing ...' printNL. |
2735 OperatingSystem sendSignal:(OperatingSystem sigTERM) to:id. |
2735 OperatingSystem sendSignal:(OperatingSystem sigTERM) to:id. |
2748 If successful, this method does NOT return and smalltalk is gone. |
2748 If successful, this method does NOT return and smalltalk is gone. |
2749 If not successful, it does return. |
2749 If not successful, it does return. |
2750 Can be used on UNIX with fork or on other systems to chain to another program." |
2750 Can be used on UNIX with fork or on other systems to chain to another program." |
2751 |
2751 |
2752 ^ self |
2752 ^ self |
2753 exec:aCommandPath |
2753 exec:aCommandPath |
2754 withArguments:argArray |
2754 withArguments:argArray |
2755 environment:nil |
2755 environment:nil |
2756 fileDescriptors:#(0 1 2) |
2756 fileDescriptors:#(0 1 2) |
2757 fork:false |
2757 fork:false |
2758 newPgrp:false |
2758 newPgrp:false |
2759 inDirectory:nil |
2759 inDirectory:nil |
2760 showWindow:showWindowBooleanOrNil |
2760 showWindow:showWindowBooleanOrNil |
2761 |
2761 |
2762 "/ never reached ... |
2762 "/ never reached ... |
2763 |
2763 |
2764 "Modified: / 12.11.1998 / 14:44:26 / cg" |
2764 "Modified: / 12.11.1998 / 14:44:26 / cg" |
2765 ! |
2765 ! |
2766 |
2766 |
2767 startProcess:aCommandString |
2767 startProcess:aCommandString |
2768 <resource: #obsolete> |
2768 <resource: #obsolete> |
2769 |
2769 |
2770 ^ self |
2770 ^ self |
2771 startProcess:aCommandString inputFrom:nil outputTo:nil |
2771 startProcess:aCommandString inputFrom:nil outputTo:nil |
2772 errorTo:nil auxFrom:nil environment:nil |
2772 errorTo:nil auxFrom:nil environment:nil |
2773 inDirectory:nil newPgrp:true showWindow:nil |
2773 inDirectory:nil newPgrp:true showWindow:nil |
2774 |
2774 |
2775 " |
2775 " |
2776 |pid| |
2776 |pid| |
2777 |
2777 |
2778 pid := OperatingSystem startProcess:'sleep 2; echo 1; sleep 2; echo 2'. |
2778 pid := OperatingSystem startProcess:'sleep 2; echo 1; sleep 2; echo 2'. |
2824 ! |
2824 ! |
2825 |
2825 |
2826 startProcess:aCommandString inputFrom:anExternalInStream outputTo:anExternalOutStream errorTo:anExternalErrStream |
2826 startProcess:aCommandString inputFrom:anExternalInStream outputTo:anExternalOutStream errorTo:anExternalErrStream |
2827 <resource: #obsolete> |
2827 <resource: #obsolete> |
2828 |
2828 |
2829 ^ self |
2829 ^ self |
2830 startProcess:aCommandString inputFrom:anExternalInStream outputTo:anExternalOutStream |
2830 startProcess:aCommandString inputFrom:anExternalInStream outputTo:anExternalOutStream |
2831 errorTo:anExternalErrStream auxFrom:nil environment:nil |
2831 errorTo:anExternalErrStream auxFrom:nil environment:nil |
2832 inDirectory:nil newPgrp:true showWindow:nil |
2832 inDirectory:nil newPgrp:true showWindow:nil |
2833 ! |
2833 ! |
2834 |
2834 |
2835 startProcess:aCommandString inputFrom:anExternalInStream outputTo:anExternalOutStream |
2835 startProcess:aCommandString inputFrom:anExternalInStream outputTo:anExternalOutStream |
2836 errorTo:anExternalErrStream auxFrom:anExternalAuxStreamOrNil environment:environment inDirectory:dir |
2836 errorTo:anExternalErrStream auxFrom:anExternalAuxStreamOrNil environment:environment inDirectory:dir |
2837 <resource: #obsolete> |
2837 <resource: #obsolete> |
2838 |
2838 |
2839 ^ self |
2839 ^ self |
2840 startProcess:aCommandString inputFrom:anExternalInStream outputTo:anExternalOutStream |
2840 startProcess:aCommandString inputFrom:anExternalInStream outputTo:anExternalOutStream |
2841 errorTo:anExternalErrStream auxFrom:anExternalAuxStreamOrNil environment:environment |
2841 errorTo:anExternalErrStream auxFrom:anExternalAuxStreamOrNil environment:environment |
2842 inDirectory:dir newPgrp:true showWindow:nil |
2842 inDirectory:dir newPgrp:true showWindow:nil |
2843 ! |
2843 ! |
2844 |
2844 |
2845 startProcess:aCommandString inputFrom:anExternalInStream outputTo:anExternalOutStream |
2845 startProcess:aCommandString inputFrom:anExternalInStream outputTo:anExternalOutStream |
2846 errorTo:anExternalErrStream auxFrom:anExternalAuxStreamOrNil environment:environment |
2846 errorTo:anExternalErrStream auxFrom:anExternalAuxStreamOrNil environment:environment |
2847 inDirectory:dir showWindow:showWindowBooleanOrNil |
2847 inDirectory:dir showWindow:showWindowBooleanOrNil |
2848 <resource: #obsolete> |
2848 <resource: #obsolete> |
2849 |
2849 |
2850 ^ self |
2850 ^ self |
2851 startProcess:aCommandString inputFrom:anExternalInStream outputTo:anExternalOutStream |
2851 startProcess:aCommandString inputFrom:anExternalInStream outputTo:anExternalOutStream |
2852 errorTo:anExternalErrStream auxFrom:anExternalAuxStreamOrNil environment:environment |
2852 errorTo:anExternalErrStream auxFrom:anExternalAuxStreamOrNil environment:environment |
2853 inDirectory:dir newPgrp:true showWindow:showWindowBooleanOrNil |
2853 inDirectory:dir newPgrp:true showWindow:showWindowBooleanOrNil |
2854 |
2854 |
2855 "Modified: / 08-11-2016 / 21:24:27 / cg" |
2855 "Modified: / 08-11-2016 / 21:24:27 / cg" |
2856 ! |
2856 ! |
2857 |
2857 |
2858 startProcess:aCommandString inputFrom:anExternalInStream outputTo:anExternalOutStream |
2858 startProcess:aCommandString inputFrom:anExternalInStream outputTo:anExternalOutStream |
2859 errorTo:anExternalErrStream auxFrom:anAuxiliaryStream inDirectory:dir |
2859 errorTo:anExternalErrStream auxFrom:anAuxiliaryStream inDirectory:dir |
2860 <resource: #obsolete> |
2860 <resource: #obsolete> |
2861 |
2861 |
2862 ^ self |
2862 ^ self |
2863 startProcess:aCommandString inputFrom:anExternalInStream outputTo:anExternalOutStream |
2863 startProcess:aCommandString inputFrom:anExternalInStream outputTo:anExternalOutStream |
2864 errorTo:anExternalErrStream auxFrom:nil environment:nil |
2864 errorTo:anExternalErrStream auxFrom:nil environment:nil |
2865 inDirectory:dir newPgrp:true showWindow:nil |
2865 inDirectory:dir newPgrp:true showWindow:nil |
2866 ! |
2866 ! |
2867 |
2867 |
2868 startProcess:aCommandString inputFrom:anExternalInStream outputTo:anExternalOutStream errorTo:anExternalErrStream inDirectory:dir |
2868 startProcess:aCommandString inputFrom:anExternalInStream outputTo:anExternalOutStream errorTo:anExternalErrStream inDirectory:dir |
2869 <resource: #obsolete> |
2869 <resource: #obsolete> |
2870 |
2870 |
2871 ^ self |
2871 ^ self |
2872 startProcess:aCommandString inputFrom:anExternalInStream outputTo:anExternalOutStream |
2872 startProcess:aCommandString inputFrom:anExternalInStream outputTo:anExternalOutStream |
2873 errorTo:anExternalErrStream auxFrom:nil environment:nil |
2873 errorTo:anExternalErrStream auxFrom:nil environment:nil |
2874 inDirectory:dir newPgrp:true showWindow:nil |
2874 inDirectory:dir newPgrp:true showWindow:nil |
2875 ! ! |
2875 ! ! |
2876 |
2876 |
2877 !AbstractOperatingSystem class methodsFor:'file access'! |
2877 !AbstractOperatingSystem class methodsFor:'file access'! |
2878 |
2878 |
2879 closeFd:anInteger |
2879 closeFd:anInteger |
5181 packagePath add:('.' "Filename currentDirectory pathName"). |
5181 packagePath add:('.' "Filename currentDirectory pathName"). |
5182 |
5182 |
5183 "/ accept the fact that sometimes, we cannot figure out, where I im |
5183 "/ accept the fact that sometimes, we cannot figure out, where I im |
5184 execPath := self pathOfSTXExecutable. |
5184 execPath := self pathOfSTXExecutable. |
5185 execPath notNil ifTrue:[ |
5185 execPath notNil ifTrue:[ |
5186 "/ |
5186 "/ |
5187 "/ the executable's directory: |
5187 "/ the executable's directory: |
5188 "/ (/opt/stx/bin/stx -> /opt/stx/bin) |
5188 "/ (/opt/stx/bin/stx -> /opt/stx/bin) |
5189 "/ |
5189 "/ |
5190 appDir := execPath asFilename directory. |
5190 appDir := execPath asFilename directory. |
5191 dirName := appDir pathName. |
5191 dirName := appDir pathName. |
5192 (packagePath includes:dirName) ifFalse:[ |
5192 (packagePath includes:dirName) ifFalse:[ |
5193 packagePath add:dirName. |
5193 packagePath add:dirName. |
5194 ]. |
5194 ]. |
5195 |
5195 |
5196 "/ |
5196 "/ |
5197 "/ the executable's parent directory: |
5197 "/ the executable's parent directory: |
5198 "/ (/opt/stx/bin/stx -> /opt/stx) |
5198 "/ (/opt/stx/bin/stx -> /opt/stx) |
5199 "/ |
5199 "/ |
5200 appDir := appDir directory. |
5200 appDir := appDir directory. |
5201 dirName := appDir pathName. |
5201 dirName := appDir pathName. |
5202 (packagePath includes:dirName) ifFalse:[ |
5202 (packagePath includes:dirName) ifFalse:[ |
5203 packagePath add:dirName. |
5203 packagePath add:dirName. |
5204 ]. |
5204 ]. |
5205 ]. |
5205 ]. |
5206 |
5206 |
5207 homeDirName := OperatingSystem getHomeDirectory. |
5207 homeDirName := OperatingSystem getHomeDirectory. |
5208 homeDirName notNil ifTrue:[ |
5208 homeDirName notNil ifTrue:[ |
5209 "/ |
5209 "/ |
5210 "/ a users private smalltalk directory in its home (login) directory: |
5210 "/ a users private smalltalk directory in its home (login) directory: |
5211 "/ $HOME/.smalltalk/packages or $HOME\smalltalk\packages |
5211 "/ $HOME/.smalltalk/packages or $HOME\smalltalk\packages |
5212 "/ |
5212 "/ |
5213 OperatingSystem isUNIXlike ifTrue:[ |
5213 OperatingSystem isUNIXlike ifTrue:[ |
5214 priv := '.smalltalk'. |
5214 priv := '.smalltalk'. |
5215 ] ifFalse:[ |
5215 ] ifFalse:[ |
5216 priv := 'smalltalk'. |
5216 priv := 'smalltalk'. |
5217 ]. |
5217 ]. |
5218 userPrivateSTXDir := homeDirName asFilename / priv. |
5218 userPrivateSTXDir := homeDirName asFilename / priv. |
5219 (userPrivateSTXDir isDirectory) ifTrue:[ |
5219 (userPrivateSTXDir isDirectory) ifTrue:[ |
5220 dirName := userPrivateSTXDir pathName. |
5220 dirName := userPrivateSTXDir pathName. |
5221 (packagePath includes:dirName) ifFalse:[ |
5221 (packagePath includes:dirName) ifFalse:[ |
5222 packagePath add:dirName |
5222 packagePath add:dirName |
5223 ] |
5223 ] |
5224 ]. |
5224 ]. |
5225 ]. |
5225 ]. |
5226 |
5226 |
5227 "/ |
5227 "/ |
5228 "/ STX_TOPDIR from the environment: |
5228 "/ STX_TOPDIR from the environment: |
5229 "/ $STX_TOPDIR/packages |
5229 "/ $STX_TOPDIR/packages |
5230 "/ |
5230 "/ |
5231 topDirName := OperatingSystem getEnvironment:'STX_TOPDIR'. |
5231 topDirName := OperatingSystem getEnvironment:'STX_TOPDIR'. |
5232 topDirName notNil ifTrue:[ |
5232 topDirName notNil ifTrue:[ |
5233 (packagePath includes:topDirName) ifFalse:[ |
5233 (packagePath includes:topDirName) ifFalse:[ |
5234 packagePath add:topDirName |
5234 packagePath add:topDirName |
5235 ]. |
5235 ]. |
5236 ]. |
5236 ]. |
5237 |
5237 |
5238 packagePath := packagePath |
5238 packagePath := packagePath |
5239 collect:[:each | |
5239 collect:[:each | |
5240 |p| |
5240 |p| |
5241 |
5241 |
5242 (p := each asFilename / 'packages') exists ifTrue:[ |
5242 (p := each asFilename / 'packages') exists ifTrue:[ |
5243 p pathName |
5243 p pathName |
5244 ] ifFalse:[ |
5244 ] ifFalse:[ |
5245 (p := each asFilename / 'Packages') exists ifTrue:[ |
5245 (p := each asFilename / 'Packages') exists ifTrue:[ |
5246 p pathName |
5246 p pathName |
5247 ] ifFalse:[ |
5247 ] ifFalse:[ |
5248 nil |
5248 nil |
5249 ]. |
5249 ]. |
5250 ]. |
5250 ]. |
5251 ] |
5251 ] |
5252 thenSelect:[:each | each notNil]. |
5252 thenSelect:[:each | each notNil]. |
5253 |
5253 |
5254 " |
5254 " |
5255 unconditionally prepend all directories from $STX_PACKAGEPATH |
5255 unconditionally prepend all directories from $STX_PACKAGEPATH |
5256 " |
5256 " |
5257 (dirName := OperatingSystem getEnvironment:'STX_PACKAGEPATH') notNil ifTrue:[ |
5257 (dirName := OperatingSystem getEnvironment:'STX_PACKAGEPATH') notNil ifTrue:[ |
5258 dirName := dirName asCollectionOfSubstringsSeparatedBy:$:. |
5258 dirName := dirName asCollectionOfSubstringsSeparatedBy:$:. |
5259 dirName reverseDo:[:eachDirectoryName| |
5259 dirName reverseDo:[:eachDirectoryName| |
5260 (packagePath includes:eachDirectoryName) ifFalse:[ |
5260 (packagePath includes:eachDirectoryName) ifFalse:[ |
5261 packagePath addFirst:eachDirectoryName. |
5261 packagePath addFirst:eachDirectoryName. |
5262 ]. |
5262 ]. |
5263 ]. |
5263 ]. |
5264 ]. |
5264 ]. |
5265 |
5265 |
5266 false ifTrue:[ |
5266 false ifTrue:[ |
5267 appDir notNil ifTrue:[ |
5267 appDir notNil ifTrue:[ |
5268 "maybe the sources are kept in a central place..." |
5268 "maybe the sources are kept in a central place..." |
5269 (appDir / 'source') isDirectory ifTrue:[ |
5269 (appDir / 'source') isDirectory ifTrue:[ |
5270 packagePath add:(appDir / 'source') pathName. |
5270 packagePath add:(appDir / 'source') pathName. |
5271 ]. |
5271 ]. |
5272 ]. |
5272 ]. |
5273 ]. |
5273 ]. |
5274 |
5274 |
5275 "maybe we are running in the build environment: XXX/stx /projects /smalltalk |
5275 "maybe we are running in the build environment: XXX/stx /projects /smalltalk |
5276 or: XXX/exept /expecco /application |
5276 or: XXX/exept /expecco /application |
5277 - if XXX/stx/libbasic exists, add XXX to the package path" |
5277 - if XXX/stx/libbasic exists, add XXX to the package path" |
5278 false ifTrue:[ |
5278 false ifTrue:[ |
5279 topDirName isNil ifTrue:[ |
5279 topDirName isNil ifTrue:[ |
5280 "appdir is now: projects" |
5280 "appdir is now: projects" |
5281 appDir := appDir directory directory. |
5281 appDir := appDir directory directory. |
5282 (appDir / 'stx' / 'libbasic') isDirectory ifTrue:[ |
5282 (appDir / 'stx' / 'libbasic') isDirectory ifTrue:[ |
5283 appDir pathName = homeDirName ifTrue:[ |
5283 appDir pathName = homeDirName ifTrue:[ |
5284 "but take care, it may be directly in the home directory" |
5284 "but take care, it may be directly in the home directory" |
5285 appDir := appDir / 'stx'. |
5285 appDir := appDir / 'stx'. |
5286 ]. |
5286 ]. |
5287 packagePath add:appDir pathName. |
5287 packagePath add:appDir pathName. |
5288 ]. |
5288 ]. |
5289 ]. |
5289 ]. |
5290 ]. |
5290 ]. |
5291 ^ packagePath |
5291 ^ packagePath |
5292 |
5292 |
5293 " |
5293 " |