diff --git a/include/options.hpp b/include/options.hpp index 0566109..a02ebd9 100644 --- a/include/options.hpp +++ b/include/options.hpp @@ -9,6 +9,7 @@ extern bool opt_minimize; extern bool g_cd; extern bool g_include; extern bool g_resolve; +extern bool g_shebang; void get_opts(); diff --git a/src/main.cpp b/src/main.cpp index 8aea7b3..8961ea3 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -194,14 +194,14 @@ int main(int argc, char* argv[]) if(destfile == "-") destfile = "/dev/stdout"; // output - std::ofstream(destfile) << sh->generate(); + std::ofstream(destfile) << sh->generate(g_shebang, 0); // don't chmod on /dev/ if(destfile.substr(0,5) != "/dev/") - ztd::exec("chmod", "+x", destfile); + ztd::exec("chmod", "+x", destfile); } else // to console { - std::cout << sh->generate(); + std::cout << sh->generate(g_shebang, 0); } } catch(ztd::format_error& e) diff --git a/src/options.cpp b/src/options.cpp index 59d3126..cc16ca8 100644 --- a/src/options.cpp +++ b/src/options.cpp @@ -8,6 +8,7 @@ bool opt_minimize=false; bool g_cd=false; bool g_include=true; bool g_resolve=true; +bool g_shebang=true; ztd::option_set gen_options() { @@ -21,6 +22,7 @@ ztd::option_set gen_options() ztd::option('o', "output", true , "Output result script to file", "file"), ztd::option('c', "stdout", false, "Output result script to stdout"), ztd::option('e', "exec", false, "Directly execute script"), + ztd::option("no-shebang", false, "Don't output shebang"), ztd::option("\r [Processing]"), ztd::option('C', "no-cd", false, "Don't cd when doing %include and %resolve"), ztd::option('m', "minimize", false, "Minimize code without changing functionality"), @@ -49,6 +51,7 @@ void get_opts() g_cd=!options['C'].activated; g_include=!options["no-include"].activated; g_resolve=!options["no-resolve"].activated; + g_shebang=!options["no-shebang"].activated; if(options["exclude-var"]) re_var_exclude=var_exclude_regex(options["exclude-var"], !options["no-exclude-reserved"]); else