@@ -42,11 +42,11 @@ class UnixShell {
4242 // User stack for exit command (don't persist this)
4343 this . userStack = [ ] ;
4444 this . environment = {
45- ' USER' : this . currentUser ,
46- ' HOME' : `/home/${ this . currentUser } ` ,
47- ' PWD' : this . currentPath ,
48- ' PATH' : '/usr/local/bin:/usr/bin:/bin' ,
49- ' SHELL' : '/bin/bash'
45+ USER : this . currentUser ,
46+ HOME : `/home/${ this . currentUser } ` ,
47+ PWD : this . currentPath ,
48+ PATH : '/usr/local/bin:/usr/bin:/bin' ,
49+ SHELL : '/bin/bash' ,
5050 } ;
5151 this . commandHistory = [ ] ;
5252 // Piped output flag
@@ -61,17 +61,17 @@ class UnixShell {
6161 createDefaultFileSystem ( username ) {
6262 return {
6363 '/' : {
64- ' home' : {
64+ home : {
6565 [ username ] : {
6666 'README.md' : '# Welcome\n\nThis is a simple Unix shell emulator.\n' ,
67- 'example.txt' : 'This is an example file.\n'
68- }
67+ 'example.txt' : 'This is an example file.\n' ,
68+ } ,
6969 } ,
70- ' etc' : {
71- ' hostname' : 'localhost\n'
70+ etc : {
71+ hostname : 'localhost\n' ,
7272 } ,
73- ' tmp' : { }
74- }
73+ tmp : { } ,
74+ } ,
7575 } ;
7676 }
7777 /**
@@ -98,7 +98,7 @@ class UnixShell {
9898 return null ;
9999 }
100100 // Validate that the saved path exists in the filesystem
101- const pathParts = savedPath . split ( '/' ) . filter ( p => p ) ;
101+ const pathParts = savedPath . split ( '/' ) . filter ( ( p ) => p ) ;
102102 let current = fileSystem [ '/' ] ;
103103 for ( const part of pathParts ) {
104104 if ( ! current || typeof current !== 'object' || ! ( part in current ) ) {
@@ -110,7 +110,7 @@ class UnixShell {
110110 return {
111111 fileSystem : fileSystem ,
112112 currentUser : savedUser ,
113- currentPath : savedPath
113+ currentPath : savedPath ,
114114 } ;
115115 }
116116 catch ( e ) {
@@ -183,7 +183,7 @@ class UnixShell {
183183 vim : this . cmd_vim . bind ( this ) ,
184184 su : this . cmd_su . bind ( this ) ,
185185 sudo : this . cmd_sudo . bind ( this ) ,
186- exit : this . cmd_exit . bind ( this )
186+ exit : this . cmd_exit . bind ( this ) ,
187187 } ;
188188 // Add custom commands (these will overwrite built-in commands if same name)
189189 for ( const [ name , handler ] of Object . entries ( customCommands ) ) {
@@ -201,8 +201,8 @@ class UnixShell {
201201 if ( path . startsWith ( '/' ) ) {
202202 return path ;
203203 }
204- const parts = this . currentPath . split ( '/' ) . filter ( p => p ) ;
205- const newParts = path . split ( '/' ) . filter ( p => p ) ;
204+ const parts = this . currentPath . split ( '/' ) . filter ( ( p ) => p ) ;
205+ const newParts = path . split ( '/' ) . filter ( ( p ) => p ) ;
206206 for ( const part of newParts ) {
207207 if ( part === '..' ) {
208208 parts . pop ( ) ;
@@ -218,7 +218,7 @@ class UnixShell {
218218 */
219219 getNode ( path ) {
220220 const fullPath = this . resolvePath ( path ) ;
221- const parts = fullPath . split ( '/' ) . filter ( p => p ) ;
221+ const parts = fullPath . split ( '/' ) . filter ( ( p ) => p ) ;
222222 let current = this . fileSystem [ '/' ] ;
223223 for ( const part of parts ) {
224224 if ( current && typeof current === 'object' && part in current ) {
@@ -254,7 +254,7 @@ class UnixShell {
254254 // Command implementations
255255 cmd_help ( ) {
256256 const commandList = Object . keys ( this . commands ) . sort ( ) ;
257- return `Available commands:\n${ commandList . map ( cmd => ` ${ cmd } ` ) . join ( '\n' ) } \n\nType any command to try it out!` ;
257+ return `Available commands:\n${ commandList . map ( ( cmd ) => ` ${ cmd } ` ) . join ( '\n' ) } \n\nType any command to try it out!` ;
258258 }
259259 cmd_ls ( args ) {
260260 // Parse flags and paths
@@ -296,7 +296,7 @@ class UnixShell {
296296 let entries = Object . keys ( node ) ;
297297 // Filter hidden files unless -a is specified
298298 if ( ! showHidden ) {
299- entries = entries . filter ( name => ! name . startsWith ( '.' ) ) ;
299+ entries = entries . filter ( ( name ) => ! name . startsWith ( '.' ) ) ;
300300 }
301301 if ( entries . length === 0 ) {
302302 continue ;
@@ -313,7 +313,8 @@ class UnixShell {
313313 } ) ;
314314 if ( longFormat ) {
315315 // Long format listing
316- const listing = entries . map ( name => {
316+ const listing = entries
317+ . map ( ( name ) => {
317318 const isDir = typeof node [ name ] === 'object' ;
318319 const perms = isDir ? 'drwxr-xr-x' : '-rw-r--r--' ;
319320 const links = isDir ? '2' : '1' ;
@@ -344,15 +345,16 @@ class UnixShell {
344345 month : 'short' ,
345346 day : 'numeric' ,
346347 hour : '2-digit' ,
347- minute : '2-digit'
348+ minute : '2-digit' ,
348349 } ) ;
349350 return `${ perms } ${ links } ${ user . padEnd ( 8 ) } ${ group . padEnd ( 8 ) } ${ size . padStart ( humanReadable ? 5 : 8 ) } ${ date } ${ name } ` ;
350- } ) . join ( '\n' ) ;
351+ } )
352+ . join ( '\n' ) ;
351353 results . push ( listing ) ;
352354 }
353355 else {
354356 // Simple format
355- const formatted = entries . map ( name => {
357+ const formatted = entries . map ( ( name ) => {
356358 const isDir = typeof node [ name ] === 'object' ;
357359 return isDir ? `${ name } /` : name ;
358360 } ) ;
@@ -430,9 +432,7 @@ class UnixShell {
430432 . join ( '\n' ) ;
431433 }
432434 cmd_history ( ) {
433- return this . commandHistory
434- . map ( ( cmd , i ) => `${ i + 1 } ${ cmd } ` )
435- . join ( '\n' ) ;
435+ return this . commandHistory . map ( ( cmd , i ) => `${ i + 1 } ${ cmd } ` ) . join ( '\n' ) ;
436436 }
437437 cmd_mkdir ( args ) {
438438 if ( ! args [ 0 ] ) {
@@ -443,7 +443,7 @@ class UnixShell {
443443 if ( ! this . canWrite ( path ) ) {
444444 return `mkdir: cannot create directory '${ args [ 0 ] } ': Permission denied` ;
445445 }
446- const parts = path . split ( '/' ) . filter ( p => p ) ;
446+ const parts = path . split ( '/' ) . filter ( ( p ) => p ) ;
447447 const dirName = parts . pop ( ) ;
448448 const parentPath = '/' + parts . join ( '/' ) ;
449449 const parent = this . getNode ( parentPath ) ;
@@ -468,7 +468,7 @@ class UnixShell {
468468 if ( ! this . canWrite ( path ) ) {
469469 return `touch: cannot touch '${ args [ 0 ] } ': Permission denied` ;
470470 }
471- const parts = path . split ( '/' ) . filter ( p => p ) ;
471+ const parts = path . split ( '/' ) . filter ( ( p ) => p ) ;
472472 const fileName = parts . pop ( ) ;
473473 const parentPath = '/' + parts . join ( '/' ) ;
474474 const parent = this . getNode ( parentPath ) ;
@@ -513,7 +513,7 @@ class UnixShell {
513513 // Process each target
514514 for ( const target of targets ) {
515515 const path = this . resolvePath ( target ) ;
516- const parts = path . split ( '/' ) . filter ( p => p ) ;
516+ const parts = path . split ( '/' ) . filter ( ( p ) => p ) ;
517517 const fileName = parts . pop ( ) ;
518518 const parentPath = '/' + parts . join ( '/' ) ;
519519 const parent = this . getNode ( parentPath ) ;
@@ -578,11 +578,11 @@ class UnixShell {
578578 const processes = [
579579 { pid : 1 , user : 'root' , tty : '?' , time : '0:01' , cmd : 'init' } ,
580580 { pid : 100 , user : this . currentUser , tty : 'pts/0' , time : '0:00' , cmd : 'bash' } ,
581- { pid : 101 , user : this . currentUser , tty : 'pts/0' , time : '0:00' , cmd : 'ps' }
581+ { pid : 101 , user : this . currentUser , tty : 'pts/0' , time : '0:00' , cmd : 'ps' } ,
582582 ] ;
583583 // Simple output format
584584 let output = ' PID TTY TIME CMD\n' ;
585- processes . forEach ( p => {
585+ processes . forEach ( ( p ) => {
586586 output += `${ String ( p . pid ) . padStart ( 5 ) } ${ p . tty . padEnd ( 12 ) } ${ p . time . padStart ( 8 ) } ${ p . cmd } \n` ;
587587 } ) ;
588588 return output ;
@@ -599,7 +599,7 @@ class UnixShell {
599599 this . userStack . push ( {
600600 user : this . currentUser ,
601601 home : this . environment . HOME ,
602- path : this . currentPath
602+ path : this . currentPath ,
603603 } ) ;
604604 this . currentUser = targetUser ;
605605 this . environment . USER = targetUser ;
@@ -648,7 +648,7 @@ class UnixShell {
648648 if ( currentDir && typeof currentDir === 'object' ) {
649649 const pattern = arg . replace ( / \* / g, '.*' ) . replace ( / \? / g, '.' ) ;
650650 const regex = new RegExp ( `^${ pattern } $` ) ;
651- const matches = Object . keys ( currentDir ) . filter ( name => regex . test ( name ) ) ;
651+ const matches = Object . keys ( currentDir ) . filter ( ( name ) => regex . test ( name ) ) ;
652652 if ( matches . length > 0 ) {
653653 expanded . push ( ...matches ) ;
654654 }
@@ -733,7 +733,7 @@ class UnixShell {
733733 let output = '' ;
734734 if ( command in this . commands ) {
735735 try {
736- this . _isPiped = ( grepPattern !== null ) ;
736+ this . _isPiped = grepPattern !== null ;
737737 output = this . commands [ command ] ( args ) ;
738738 this . _isPiped = false ;
739739 }
@@ -747,7 +747,7 @@ class UnixShell {
747747 // Apply grep filter if present
748748 if ( grepPattern !== null && output ) {
749749 const lines = output . split ( '\n' ) ;
750- const filtered = lines . filter ( line => {
750+ const filtered = lines . filter ( ( line ) => {
751751 let matches ;
752752 if ( grepFlags . ignoreCase ) {
753753 matches = line . toLowerCase ( ) . includes ( grepPattern . toLowerCase ( ) ) ;
@@ -781,7 +781,7 @@ class UnixShell {
781781 */
782782 writeToFile ( filePath , content , mode ) {
783783 const fullPath = this . resolvePath ( filePath ) ;
784- const parts = fullPath . split ( '/' ) . filter ( p => p ) ;
784+ const parts = fullPath . split ( '/' ) . filter ( ( p ) => p ) ;
785785 const fileName = parts . pop ( ) ;
786786 const parentPath = '/' + parts . join ( '/' ) ;
787787 const parent = this . getNode ( parentPath ) ;
@@ -848,7 +848,7 @@ class UnixShell {
848848 const parts = partial . trim ( ) . split ( / \s + / ) ;
849849 if ( parts . length === 1 ) {
850850 const prefix = parts [ 0 ] ;
851- const commands = Object . keys ( this . commands ) . filter ( cmd => cmd . startsWith ( prefix ) ) ;
851+ const commands = Object . keys ( this . commands ) . filter ( ( cmd ) => cmd . startsWith ( prefix ) ) ;
852852 return { type : 'command' , matches : commands , prefix } ;
853853 }
854854 const pathPrefix = parts [ parts . length - 1 ] ;
@@ -865,8 +865,8 @@ class UnixShell {
865865 return { type : 'path' , matches : [ ] , prefix : pathPrefix } ;
866866 }
867867 const matches = Object . keys ( node )
868- . filter ( name => name . startsWith ( filePrefix ) )
869- . map ( name => {
868+ . filter ( ( name ) => name . startsWith ( filePrefix ) )
869+ . map ( ( name ) => {
870870 const isDir = typeof node [ name ] === 'object' ;
871871 return isDir ? name + '/' : name ;
872872 } ) ;
0 commit comments