none
CMD有类似于Linux Bash中有着“``”“命令替换”。功能或方法么? RRS feed

  • 常规讨论

  • gcc base.c -o base `pkg-config --cflags --libs gtk+-2.0`

    例如,上面命令pkg-config --cflags --libs gtk+-2.0运行结果是:

    -mms-bitfields -ID:/Programs/GTK/include/gtk-2.0 -ID:/Programs/GTK/lib/gtk-2.0/include -ID:/Programs/GTK/include/atk-1.0 -ID:/Programs/GTK/include/cairo -ID:/Programs/GTK/include/pango-1.0 -ID:/Programs/GTK/include/glib-2.0 -ID:/Programs/GTK/lib/glib-2.0/include -ID:/Programs/GTK/include/freetype2 -ID:/Programs/GTK/include  -Wl,-luuid -LD:/Programs/GTK/lib -lgtk-win32-2.0 -lgdk-win32-2.0 -limm32 -lshell32 -lole32 -latk-1.0 -lgdk_pixbuf-2.0 -lpangocairo-1.0 -lcairo -lpangoft2-1.0 -lpangowin32-1.0 -lgdi32 -lfreetype -lz -lfontconfig -lpango-1.0 -lm -lgobject-2.0 -lgmodule-2.0 -lglib-2.0 -lintl  

    然后它会先执行pkg-config --cflags --libs gtk+-2.0,然后把其执行结果替换到`pkg-config --cflags --libs gtk+-2.0`,使上面第一行这条命令实际是:

    gcc base.c -o base -mms-bitfields -ID:/Programs/GTK/include/gtk-2.0 -ID:/Programs/GTK/lib/gtk-2.0/include -ID:/Programs/GTK/include/atk-1.0 -ID:/Programs/GTK/include/cairo -ID:/Programs/GTK/include/pango-1.0 -ID:/Programs/GTK/include/glib-2.0 -ID:/Programs/GTK/lib/glib-2.0/include -ID:/Programs/GTK/include/freetype2 -ID:/Programs/GTK/include  -Wl,-luuid -LD:/Programs/GTK/lib -lgtk-win32-2.0 -lgdk-win32-2.0 -limm32 -lshell32 -lole32 -latk-1.0 -lgdk_pixbuf-2.0 -lpangocairo-1.0 -lcairo -lpangoft2-1.0 -lpangowin32-1.0 -lgdi32 -lfreetype -lz -lfontconfig -lpango-1.0 -lm -lgobject-2.0 -lgmodule-2.0 -lglib-2.0 -lintl这样执行了,这个过程就是“命令替换”:这里使用了“命令替换”。命令替换(command substitution)使得可以捕获一个命令的输出而在另一个命令中替换它。这个单引号不是回车键左边的那个,而是ESC键下面的那个。

    在Windows下如何做到这个呢?

    2013年4月5日 2:49

全部回复