mubaris / yes Goto Github PK
View Code? Open in Web Editor NEWyes - Implementation of simple and dangerous yes command in various languages. :+1:
License: MIT License
yes - Implementation of simple and dangerous yes command in various languages. :+1:
License: MIT License
When calling BUILD-FAIL
, the BUILD_LASTEXIT
variable is being set. However it is only cleared in BUILT
and changed in BUILD-RUN
.
This leads to a scenario where if after calling BUILD-FAIL
the next language is missing a compiler this will not be indicated. It also messes the layout of the messages printed.
Example:
BUILD-FAIL "TODO BUILD SCRIPT"
.fish
so case
is not matched - it skips to BUILD-END
BUILD-LASTEXIT
is still set to "FAIL"
it exits without printing anything.BUILD-END() {
# Fail command.
if [ "${BUILD_LASTEXIT}" = "FAIL" ]; then
return 0;
fi
...
Using Mono
Most implementations seem a little bit inefficient, for example the Java version could be optimized to this:
class yes {
public static void main (String[] args) {
if (args.length == 0) {
while (true) {
System.out.println("y");
}
} else {
String line = "";
for (String arg : args) {
line = line + arg + " ";
}
line = line.substring(0, line.length() - 1);
while (true) {
System.out.println(line);
}
}
}
}
We first build the string which will be one line, and then simply dump that string into the output stream. This removes the need for the system to constantly parse "%s "
, it also removes that trailing space from each line which shouldn't be there.
As a sidenote, yes, I could have used a StringBuilder
, but opted against it for simplicity reasons and simply because the string, hopefully, never becomes that large to warrant a StringBuilder
there.
The same applies to the C, Go, PHP, Python versions, and to a lesser extend to nearly all other versions, which are constantly looping over the arguments instead of caching the line once.
Each file should sport their build and execution instructions, ideally in the header as comments, maybe even required versions (for example the Java version requires Java 8).
That would allow every one to build and run every file, no matter if they are familiar with the toolchain or not. For some files, like the shell, it's as simple as executing the file, others, like the Java version, require a two step process (build and execute).
This will max out your cpu and then you die
There are a couple languages that are missing in the build.sh script. If you know how to run/build any of the following languages, we would be thankful if you could help out and add it.
This might be overkill, but if somebody wants to do it (or just run ildasm.exe)
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.