Search code examples
shellterminalcygwinmkdir

make directory with bash builtin


I am writing bash script for Windows 7 and have limitation to bash.exe

mkdir -p does not work (command not found)

I am looking for any replacement/cheat with bash builtins. (the -p flag is not mandatory, could do this with a loop instead)

There is some idea to Transform a file into directory or some other nice hack only a expert will know. This question is not about how to fix a missing mkdir binary, but about reducing dependencies of (broken) core utils.

this are the available bash builtins:

& (( . : [ [[ alias bg bind break builtin caller case cd command compgen complete compopt continue coproc declare dirs disown echo enable eval exec exit export false fc fg for function getopts hash help history if jobs kill let local logout mapfile popd printf pushd pwd read readarray readonly return select set shift shopt source suspend test time times trap true type typeset ulimit umask unalias unset until wait while {

if not possible with bash builtins there are some external utils available. There is already one example which depends on cp
Create a new folder using bash without mkdir command
this is all i have:

bash blobpack blobunpack bzip2 cat chmod clear cpio cut dd dhtbsign dos2unix dumpimage elftool expr file find futility grep gzip hexdump kernel_dump loki_tool ls lz4 lzop mac2unix mboot md5sum mkbootimg mkimage mkmtkhdr mv printf pxa-mkbootimg pxa-unpackbootimg rkcrc rm sed stat sudo tail tar touch unix2dos unix2mac unpackbootimg unpackelf xz

Note: I have edited the question to clarify the needs.


Solution

  • This trick can be helpful to run Windows md shell builtin from within bash script

    echo -e 'md %*\r' > mkdir.bat
    ./mkdir.bat test