kolibrios-fun/programs/cmd/trunk
Andrey Halyavin (halyavin) 065b8d32b2 programs sources added
git-svn-id: svn://kolibrios.org@31 a494cfbc-eb01-0410-851d-a64ba20cac60
2006-01-03 09:43:31 +00:00
..
build_en.bat programs sources added 2006-01-03 09:43:31 +00:00
build_ru.bat programs sources added 2006-01-03 09:43:31 +00:00
cmd.asm programs sources added 2006-01-03 09:43:31 +00:00
cmdipc.inc programs sources added 2006-01-03 09:43:31 +00:00
macros.inc programs sources added 2006-01-03 09:43:31 +00:00
readme.txt programs sources added 2006-01-03 09:43:31 +00:00

  CMD - Èíòåðïðåòàòîð êîìàíäíîé ñòðîêè äëÿ Menuet
        Íàïèñàíî by Chemist dmitry_gt@tut.by

        Âåðñèÿ 0.27

	Ðóññêèé òåêñò íåìíîãî ïîíèæå.

-----------------------------------------------------------------------

  CMD - Command Line Interpreter for Menuet
	Copyleft Chemist - dmitry_gt@tut.by

	Version 0.27

	As my english is not well, I will tell a few words about this
	program. It supports 14 commands, such as cp (copy file),
	rn (rename file), ps (process list), kill (kill process) etc.
	You can type 'help' after starting this shell to examine with
	other commands. Also it uses several special symbols, such as
	&, /, . and +. Use & sumbol to enter params. For example,
	type tinypad&cmd.asm to open cmd.asm file in tinypad editor.
	/ symbol is used to run special command scripts for CMD.
	It's syntax is: /filename without extension (For example,
	type /autoexec to execute autoexec.cmd file for CMD). And +
	symbol is used in cp and rn commands. You must type
	cp example.asm+example.bak to copy example.asm file to
	example.bak. Use dot to launch program, if CMD command and
	other external command match. For example, type help for
	'help' command or type .help to run 'help' program.

	This shell supports executeing special command
	scripts (something like .BAT files in MS-DOS). This files
	have an .CMD extinsion and u must use / symbol to execute it.
	U can use any CMD commands and filenames in this scripts.
	But you can't run other scripts from any CMD script (/ symbol).
	I recommed to use tipypad editor to edit this scripts and do
	not leave spaces and other symbols after commands in the script
	file, because it's executeing is not very developed yet.
	And it's strongly recommended to use ends command in the end
	of the script, because there are some problems with redrawing
	the window after executing scripts without this command.
	Every time when you launch CMD autoexec.cmd file automatically
	executes. You can edit or delete this file if you want.

	This version of CMD shell supports IPC. It mean, than you can
	write your own programs for this shell. Look at .ASM files in
	the Examples directory in this archive. I think that you will
	understand them without any difficulties. Do not forget, that
	you need CMDIPC.ASM file to compile this sources. It's
	recommended to compile it with MACROS.INC file (included in
	this archieve) to make their size smaller.

	And now about some bugs etc.

	----------------------------

	I've noticed, that there are some difficulties with files with
	1 or 2 symbols in extension. I recommend do not use such files
	not only in CMD, but almost in every programs in MeOS. It's
	possible to create such file in tinypad, and then (in MS-DOS or
	Windows) Scandisk will find errors in filenames etc. CMD do
	not support properly such filenames now.

	In CMDIPC.INC and CMD.ASM I used 5-th function (pause), because
	I need it when CMD communicates with IPC programs. It's
	even possible, that it will not enough 1/100 sec. on slow PC's,
	because CMD need this time to finish IPC-command from other
	IPC-program. U can change ebx value in CMDIPC.ASM in pause1:
	if you want. But it slows communication betwen CMD and
	IPC-programs for CMD. I hope, that you understand my words. :)

	Now (in this version) you can launch only one CMD shell.
	Because it's difficult to make communication betwen several
	copyes of CMD in memory and IPC-programs. I will solve this
	problem in future.

	I've tested this shell only on Ivan Poddubny's russian
	distributive. Also I recommend you to use it. :) CMD shell
	is included into this distributive (but possible not it's
	final version).

	Source code of this program is not optimized yet. I have such
	manner of programming from my childhood that my source code
	is not very "compact"

	etc. ;-)

	And now other information:
	--------------------------

	I do not want CMD design to change. I like white symbols on
	the black background. If you want to change the source and
	redistribute it, please, do not change it's design. :)

	If you will find some bugs or you have some wishes (or even you
	correct some mistakes in my english texts) -
	email me: dmitry_gt@tut.by

	And this program is distributed "as is". Use it on your own
	risk. ;-)

	And again - my English is not well. :)

	That's all!

	19.06.2004,
	Chemist
	
	Now russian text :)

-----------------------------------------------------------------------
 
  Äîñòóïíûå êîìàíäû:

	ls [filename] - âûâîä ñïèñêà ôàéëîâ. Åñëè ïîñëå êîìàíäû 
                        óêàçàòü èìÿ ôàéëà, òî êîìàíäà ïðîâåðèò åãî 
                        íà íàëè÷èå.

	cp [source_file+destination_file] - êîìàíäà äëÿ 
                        êîïèðîâàíèÿ ôàéëîâ. Ïðîâåðÿåò ôàéëû íà 
                        íàëè÷èå, è â ñëó÷àå îøèáêè âûâîäèò 
                        ñîîòâåòñòâóþùèå ñîîáùåíèÿ.

        rn [source_file+destination_file] - êîìàíäà äëÿ 
                        ïåðåèìåíîâàíèÿ ôàéëîâ. Òàê æå 
                        ïðîâåðÿåò ôàéëû íà íàëè÷èå, è â 
                        ñëó÷àå îøèáêè âûâîäèò ñîîòâåòñòâóþùèå
			ñîîáùåíèÿ.

	ps            - âûâîä èíôîðìàöèè î ïðîöåññàõ â ñèñòåìå.

        kill          - ïðåðâàòü ïðîöåññ â ñèñòåìå. Âíèìàíèå, 
                        ïîñëå êîìàíäû ñëåäóåò ââîäèòü 4-õ 
                        çíà÷íûé íîìåð ïðîöåññà, à íå PID. Íîìåð 
                        ïðîöåññà óêàçàí â ïîñëåäíåé êîëîíêå ïðè 
                        âûçîâå êîìàíäû ps.

	help          - âûâîä êðàòêîé ñïðàâî÷íîé èíôîðìàöèè.

        ver           - âûâîä èñïîëüçóåìîé âåðñèè èíòåðïðåòàòîðà.

        cls           - î÷èñòêà ýêðàíà.

        exit          - âûõîä èç èíòåðïðåòàòîðà.

        del [filename] - óäàëèòü ôàéë ñ ðàìäèñêà. Ïðè îòñóòñòâèè 
                        çàïðàøèâàåìîãî ôàéëà áóäåò âûâåäåíî 
                        ñîîòâåòñòâóþùèå ñîîáùåíèå îá îøèáêå.

	shutdown      - çàâåðøèòü ðàáîòó ñèñòåìû.

	pause         - îæèäàòü íàæàòèå êëàâèøè. Èñïîëüçóåòñÿ äëÿ 
                        "âçàèìîäåéñòâèÿ" ïîëüçîâàòåëÿ ñ êîìàíäíûìè 
                        ñêðèïòàìè äëÿ êîíñîëè (èíòåðïðåòàòîðà). 
                        Íàïðèìåð, ìîæíî èñïîëüçîâàòü äàííûé ñêðèïò 
                        
                        echo Do you want to delete cmd.asm?
                        pause
                        del cmd.asm

                        äëÿ òîãî, ÷òîáû ïîèíòåðåñîâàòüñÿ ìíåíèåì 
                        ïîëüçîâàòåëÿ, õî÷åò ëè îí óäàëèòü ôàéë cmd.asm 
                        èëè ïðåðâàòü ðàáîòó ñêðèïòà.

	pause >nul	Òî æå ñàìîå, òîëüêî áåç âûâîäà ñòðîêè
			'Press ane key to continue (ESC - cancel)'

	echo [text]     - âûâîä òåêñòà íà ýêðàí. Ïðåäíàçíà÷åíà äëÿ 
                        ïîäà÷è ïîëüçîâàòåëþ èíôîðìàöèè èç êîìàíäíîãî 
                        ñêðèïòà. Åñëè ââåñòè êîìàíäó echo áåç òåêñòà, 
                        òî ýòî ïðîñòî âûçîâåò ïåðåõîä íà ñëåäóþùóþ 
                        ñòðîêó.

	ends            - êîìàíäà, äîñòóïíàÿ òîëüêî èç èñïîëíÿåìûõ 
                        ñêðèïòîâ. Ñëóæèò äëÿ èõ êîððåêòíîãî çàâåðøåíèÿ,
                        ò.ê. èíîãäà êîìàíäíûå ñêðèïòû, ó êîòîðûõ â 
                        êîíöå ñòîÿëè íåíóæíûå ïðîáåëû èëè ñèìâîëû EOL, 
                        âûçûâàëè ïðîáëåìû ñ ïåðåðèñîâêîé îêíà. Ñêîðåå 
                        âñåãî ýòà êîìàíäà ïðèñóòñòâóåò â êîíñîëè 
                        âðåìåííî è áóäåò óáðàíà ïîñëå ðåøåíèÿ ýòîé 
                        ïðîáëåìû.

-----------------------------------------------------------------------
	
  Óïðàâëÿþùèå ñèìâîëû:

	/[êîìàíäíûé ñêðèïò] - ïðåäíàçíà÷åí äëÿ âûçîâà íà èñïîëíåíèå 
                        êîìàíäíîãî ñêðèïòà èç êîíñîëè. Íå ìîæåò 
                        èñïîëüçîâàòüñÿ â íåïîñðåäñòâåííî â ñàìèõ 
                        êîìàíäíûõ ñêðèïòàõ. Åñëè ðàñøèðåíèå èñïîë-
                        íÿåìîãî ñêðèïòà .cmd, òî åãî óêàçûâàòü 
                        íåîáÿçàòåëüíî.

	& - äàííûé ñèìâîë èñïîëüçóåòñÿ äëÿ ïåðåäà÷è âûçûâàåìîé 
            ïðîãðàììå ïàðàìåòðîâ. Íàïðèìåð, êîìàíäà tinypad&cmd.asm 
            ïåðåäàñò ïðîãðàììå tinypad ïàðàìåòð cmd.asm, 
            ñîîòâåòñòâåííî, tinypad îòêðîåò ôàéë cmd.asm.

	+ - ðàçäåëÿåò èìåíà èñõîäíîãî è ðåçóëüòèðóþùåãî ôàéëîâ â 
            êîìàíäàõ cp è rn.

	. - çàïóñêàåò óêàçàííóþ ïîñëå òî÷êè ïðîãðàììó, äàæå åñëè îíà
	    ñîâïàäàåò ñ êîìàíäîé CMD. Íàïðèìåð, help - âûïîëíèòü
	    êîìàíäó 'help', íî .help - çàïóñòèòü âíåøíþþ ïðîãðàììó
	    'help' (õîòÿ òàêîé ïîêà âðîäå è íåòó :).

-----------------------------------------------------------------------

  Íàâèãàöèÿ ïî êîíñîëè:

	Äëÿ ðåäàêòèðîâàíèÿ êîìàíäíîé ñòðîêè èñïîëüçóþòñÿ êëàâèøè ESC, 
        BACKSPACE. ESC - äëÿ óäàëåíèÿ âñåé êîìàíäíîé ñòðîêè, 
        BACKSPACE - äëÿ óäàëåíèÿ ïîñëåäíåãî ââåäåííîãî ñèìâîëà. Ïî 
        ìîåìó ìíåíèþ, èñïîëüçîâàíèå òàêèõ êëàâèø, êàê HOME, END, ARROW 
        KEY etc. íå èìååò ñìûñëà, ò.ê. ââîäèìûå êîìàíäû ñëèøêîì 
        ïðîñòû è íå òðåáóþò ïîäðîáíîãî ðåäàêòèðîâàíèÿ. Ïîýòîìó ÿ 
        îñòàâèë âñå ïðèìåðíî òàê, êàê áûëî â MS-DOS 6.22.

        Êëàâèøà UPARROW èñïîëüçóåòñÿ äëÿ ïîâòîðà ïîñëåäíåé ââåäåííîé 
        êîìàíäû.

-----------------------------------------------------------------------

  Èñïîëüçîâàíèå IPC âî âíåøíèõ ïðîãðàììàõ:

	Âû ìîæåòå ïèñàòü ïðîãðàììû, âçàèìîäåéñòâóþùèå ñ CMD ÷åðåç IPC.
	Â îñíîâíîì, ÿ ïîëàãàþ, ýòî ìîæåò ïðèãîäèòñÿ äëÿ íàïèñàíèÿ
	êîíñîëüíûõ ïðèëîæåíèé äëÿ ñàìîãî CMD (õîòÿ âîçìîæíî è äðóãîå).
	
	Äëÿ ýòîãî, ê âàøåé ïðîãðàììå âàì íåîáõðäèìî ïîäêëþ÷èòü ôàéë
	CMDIPC.INC (Åñòåñòâåííî, îò ýòîãî ðàçìåð ïðîãðàììû ïîñëå
	êîìïèëÿöèè íåñêîëüêî óâåëè÷èòñÿ). Ïîñëå ýòîãî âàì ñòàíóò
	äîñòóïíû 6 ôóíêöèè IPC, êîòîðûå âû ìîæåòå âûçûâàòü ñ ïîìîùüþ
	call èç ñâîåé æå ïðîãðàììû. Âîò èõ îïèñàíèå:

	---------------------------------------------------------------

	initipc - èíèöèàëèçàöèÿ IPC äëÿ ðàáîòû ñ CMD.

	call initipc - èíèöèàëèçèðîâàòü IPC äëÿ ðàáîòû ñ CMD.

	ÂÍÈÌÀÍÈÅ! Èñïîëüçóéòå â ñàìîì íà÷àëå ïðîãðàììû. CMD áóäåò æäàòü
		  òîëüêî 10/100 ñåêóíäû äëÿ òîãî, ÷òîáû ïîëó÷èòü
		  ñîîáùåíèå ïî IPC (õîòÿ ýòîãî âïîëíå äîñòàòî÷íî).

	---------------------------------------------------------------

	print   - âûâåñòè ñòðîêó â ýêðàí CMD.

	mov eax,strlen
	mov ebx,string
	call print

	Ãäå strlen - äëèíà ñòðîêè â áàéòàõ,
	string     - óêàçàòåëü íà ñòðîêó.

	call print - âûâîä ñòðîêè.

	---------------------------------------------------------------

	cls     - î÷èñòèòü ýêðàí CMD.

	call cls - âûçâàòü î÷èñòêó ýêðàíà.

	---------------------------------------------------------------

	eol     - ïðîïóñòèòü ñòðîêó.

	call eol - âûçâàòü ïðîïóñ ñòðîêè.

	---------------------------------------------------------------

	getkey  - ñ÷èòàòü êîä íàæàòîé êëàâèøè â CMD.

	call getkey - îæèäàòü íàæàòèÿ êëàâèøè è ñ÷èòàòü åå êîä.

	Âûâîä: byte [key] - êîä íàæàòîé êëàâèøè.

	ÂÍÈÌÀÍÈÅ: Ïîñëå çàïóñêà ïðîãðàììû èç CMD, êîòîðàÿ
		  ïîääåðæèâàåò IPC, òî îêíî CMD àêòèâèðóåòñÿ ñðàçó
		  ïîñëå çàïóñêà ïðîãðàììû. Ïîýòîìó, óæå íå íóæíî
		  òûêàòü ìûøêîé íà îêíî äëÿ òîãî, ÷òîáû ââåñòè
		  ÷òî-íèáóäü â êîíñîëü, êàê ýòî áûëî â ïðîøëûõ âåðñèÿõ.

	---------------------------------------------------------------

	endipc  - Çàâåðøèòü ðàáîòó IPC-ïðîãðàììû.

	call endipc - çàâåðøèòü ïðîãðàììó.

	---------------------------------------------------------------

	Âîîáùåì, âû ìîæåòå ïîñìîòðåòü ôàéë HELLO.ASM, êîòîðûé ëåæèò â
	ýòîì àðõèâå. Òàì âñå äîëæíî áûòü ïîíÿòíî. Åñòåñòâåííî, íèêòî
	âàì íå ìåøàåò èñïîëüçîâàòü ïàðàìåòðû â IPC-ïðîãðàììàõ äëÿ CMD.
	Ñìîòðèòå ïðèìåð PARAM.ASM.

	Êñòàòè, â ñàìîì CMD è â CMDIPC.INC èñïîëüçóåòñÿ 5-ÿ ôóíêöèÿ
	(ïàóçà) äëÿ òîãî, ÷òîáû	äàòü âðåìÿ äðóã-äðóãó âûïîëíèòü
	òðåáóåìûå îò íèõ ÷åðåç IPC äåéñòâèÿ. È åñëè ó âàñ êîìï ñèëüíî
	òîðìîçíþ÷èé, òî âîçìîæíî, âûäåëåííîãî âðåìåíè áóäåò
	íåäîñòàòî÷íî. Ýòî íå ñëîæíî ïîëå÷èòü, óâåëè÷èâ çíà÷åíèå
	ebx ïåðåä âûçîâîì ôóíêöèè ÿäðà (eax,5 - ïàóçà). Â ïðîòèâíîì
	ñëó÷àå ìîãóò ïîâûëåòàòü âûçîâû IPC èëè ÷òî-íèáóäü âîîáùå
	çàâèñíåò (ïåðâîå - âåðîÿòíåå). Íî, åñòåñòâåííî, íè÷åãî
	ñòðàøíîãî â ýòîì íåò. ;-)

-----------------------------------------------------------------------

  Èçâåñòíûå îøèáêè è íåäîðàáîòêè:
	
	Ïðè ðàáîòå ñ êîíñîëüþ CMD è ñèñòåìîé MenuetOS âîîáùå, ÿ 
	çàìåòèë,÷òî íåêîòîðûå ñîçäàííûå â Menuet ôàéëû íå 
	âîñïðèíèìàþòñÿ MS-DOS. Ýòî â ïåðâóþ î÷åðåäü êàñàåòñÿ ôàéëîâ, 
	ñ èìåíàìè òèïà 1.1, b.bb è ò.ä. Ïîýòîìó âîçìîæíû ðàçëè÷íûå 
	òóïèêîâûå ñèòóàöèè ïðè âçàèìîäåéñòâèè ñîçäàííûõ èëè 
	êîïèðîâàííûõ ôàéëîâ â MeOS ñ âîñïðèÿòèåì èõ â MS-DOS è Windows
	ñèñòåìàõ. È êàñàåòñÿ ýòî íå òîëüêî CMD, íî, íàïðèìåð, è 
	òèíèïàäà. Ïîýòîìó ÿ ðåêîìåíäóþ èñïîëüçîâàòü â Menuet ôàéëû èëè
	áåç ðàñøèðåíèÿ âîîáùå, èëè ñ ïîëíûì ðàñøèðåíèåì (çàíèìàþùèì
	âñå 3 áàéòà, ò.å. filename.ext,	à íå filename.ex). Â ïðèíöèïå
	ìåõàíèçì êîìàíä LS, LS èìÿ_ôàéëà, CP, DEL è RN èçìåíåí, íî
	ïîêà íåò ñîâìåñòèìîñòè ìåæäó ðàçëè÷íûìè	ïðîãðàììàìè, 
	ðàáîòàþùèìè ñ ôàéëàìè â Menuet. Ò.å. äàæå âîçìîæíî,
	÷òî âû íå ñìîæåòå ðàáîòàòü â êîíñîëè ñ ôàéëîì, ñîçäàííîì â 
	òèíèïàäå, à ïîòîì skandisk âîîáùå âûäàñò îøèáêó ïðè ïðîâåðêå 
	ôàéëîâîé ñòðóêòóðû äèñêåòû, êîãäà íàòêíåòñÿ íà ýòîò ôàéë, è îí 
	íå áóäåò ÷èòàåì èç windows èëè MS-DOS.  ïðèíöèïå, ÿ òåñòèðîâàë 
	ïðîãðàììó òîëüêî íà ìîåì PC, ïîýòîìó âîçìîæíî âñ¸. :)

	P.S. Êîìàíäà LS ïîêàæåò ïîëíîñòüþ âñå ôàéëû íà ðàìäèñêå, â òîì
	÷èñëå òå, êîòîðûå ñîçäàíû íåïðàâèëüíî è íå áóäóò ðàáîòàòü â
	MS-DOS, LS èìÿ_ôàéëà è ò.ä. ìîæåò óæå èõ íå çàìåòèòü. Â 
	ïðèíöèïå òàêàÿ æå êàðòèíà áóäåò è â windows. Ò.å. âû ñìîæåòå
	ëèöåçðåòü èìåíà ýòèõ ôàéëîâ, íàïðèìåð, â windows commander'e,
	íî áëîêíîò èõ íå îòêðîåò.
       
	Äëÿ òîãî, ÷òîáà äàòü âðåìÿ CMD îáðàáîòàòü IPC-çàïðîñ, â
	CMDIPC.ASM ìíå ïðèøëîñü èñïîëüçîâàòü 5-þ ôóíêöèþ (ïàóçà),
	ïîýòîìó íåìíîãî çàìåäëÿåòñÿ âðåìÿ ïîëó÷åíèÿ íîâûõ IPC-çàïðîñîâ.

	Â äàííîé âåðñèè âû íå ìîæåòå çàïóñêàòü áîëüøå îäíîãî
	òåðìèíàëà CMD îäíîâðåìåííî. Ýòî ñâÿçàíî ñ òåì, ÷òî ÿ åùå íå
	äîáàâèë âîçìîæíîñòè ðàáîòû íåñêîëüêèõ êîíñîëåé ñ
	IPC-ïðîãðàììàìè îäíîâðåìåííî.

	Êîä ïðîãðàììû íà äàííûé ìîìåíò íåîïòèìèçèðîâàí.
	
	etc. :)

-----------------------------------------------------------------------

	Âìåñòå ñ ïðîãðàììîé ïîñòàâëÿåòñÿ ôàéë autoexec.cmd, êîòîðûé 
        àâòîìàòè÷åñêè èñïîëíÿåòñÿ ïðè çàïóñêå èíòåðïðåòàòîðà. Åãî 
        ìîæíî óäàëèòü ïðè íåíàäîáíîñòè.

	Äëÿ âûçîâà ïðèìåðà èñïîëíÿåìîãî ñêðèïðà íàáåðèòå /example

	Âñâÿçè ñ ìîëîäîñòüþ è ÷àñòè÷íîé íåäîðàáîòàííîñòè ñàìîé 
	ïðîãðàììû âîçìîæíû îøèáêè â å¸ ðàáîòå, î êîòîðûõ ïðîñüáà 
        ñîîáùàòü íà dmitry_gt@tut.by

	Â áëèæàéøåå âðåìÿ íå ïëàíèðóåòñÿ íîâûõ íîâîââåäåíèé â êîíñîëü, 
        ò.ê. íà å¸ äîðàáîòêó óõîäèò ìíîãî âðåìåíè è ÿ ñ÷èòàþ, ÷òî îíà 
        è íà äàííûé ìîìåíò áîëåå-ìåíåå ôóíêöèîíàëüíà (â ìàñøòàáàõ 
        MenuetOS, êîíå÷íî). ß ñ÷èòàþ, ÷òî ðàöèîíàëüíåå áóäåò ñêîíöåíò-
        ðèðîâàòüñÿ íà óñòàíåíèè áàãîâ è íåäîðàáîòîê â ïðîãðàììå.

	Åñëè êòî-íèáóäü ïîæåëàåò äîäåëàòü ïðîãðàììó, òî ÿ áû ïîïðîñèë
	íå èçìåíÿòü å¸ äèçàéí (ìíå îí íðàâèòñÿ ;-) ).

	Î âñåõ îøèáêàõ ( òîì ÷èñëå ãðàììàòè÷åñêèõ â àíãëèéñêîì òåêñòå)
 	ïðîñüáà ñîîáùàòü íà dmitry_gt@tut.by

	È åùå çàáûë ñêàçàòü, òî ïðîãðàììà ðàñïîñòðàíÿåòñÿ "as is", è
	àâòîð íå íåñåò îòâåòñòâåííîñòè çà âîçìîæíûé óùåðá, ïðè÷èíåííûé
	ïðîãðàììîé.

	19.06.2004,
	Chemist