Git Product home page Git Product logo

mubaris / yes Goto Github PK

View Code? Open in Web Editor NEW
86.0 7.0 42.0 101 KB

yes - Implementation of simple and dangerous yes command in various languages. :+1:

License: MIT License

C 4.08% C++ 2.75% Go 2.21% JavaScript 2.11% Python 1.73% Ruby 0.59% Java 2.08% Perl 0.48% Lua 0.53% Shell 50.66% Scala 0.82% Erlang 0.61% D 0.87% PHP 22.91% Rust 1.10% Swift 0.75% AppleScript 0.91% Brainfuck 0.70% C# 0.81% Objective-C 3.32%
linux terminal yes command-line multiple-languages

yes's Introduction

yes

About yes

The yes command is used to output y, or whatever word you choose, forever. ๐Ÿ”

yes

Description

The yes command outputs the same string, STRING, in a constant stream. If STRING is not specified, the word it repeats is y. ๐Ÿ”

yes dates back to a time before Unix commands included the "force" (-f) option, which for many commands is the same as answering "yes" to all prompts.

yes can be used to do something very similar: if the output of yes is piped to a command, it will effectively answer "yes" to any confirmation prompts.

yes Syntax

yes [STRING]...

yes Output

y
y
y
y
y
y
.
.
.

Dangerous yes

Redirecting output to a file

yes can be dangerous also. If you redirect the output stream of yes to a file, it will eat up your storage space. ๐Ÿ’ฃ

$ yes >> yes.txt
^Z

$ du -h yes.txt
1007M yes.txt

I ran the command only for 10 Seconds. And It consumed almost 1 GB. ๐Ÿ’ฅ

Nested yes

yes takes an argument and prints it infinitely. What if you take yes as argument itself. ๐Ÿ’ฃ

$ yes `yes`

You tell me what happens. ๐Ÿ˜œ

yes's People

Contributors

anbenson avatar bgschiller avatar cg-cnu avatar cherneydh avatar dchan3 avatar jan-schreib avatar jaredbriskman avatar jightuse avatar jrgoldfinemiddleton avatar jvitkauskas avatar krazune avatar ladydascalie avatar leonid-rousniak avatar lucaschimweg avatar mewa avatar mubaris avatar nockc avatar osleg avatar patolar avatar platinumthinker avatar quamv avatar skrambol avatar suve avatar thebinaryfox avatar theoxo avatar umlaeute avatar volomas avatar wkbraid avatar ybbat avatar zvonimirr avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

yes's Issues

Missing languages in build script.

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.

  • D
  • Erlang
  • Haskell
  • Lisp
  • Lua
  • Rust
  • Scala

Implementations seem inefficient.

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.

Files should have their build and execution instructions attached.

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).

BUILD_LASTEXIT is not cleared

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:

  1. Erlang fails with BUILD-FAIL "TODO BUILD SCRIPT".
  2. I don't have fish so case is not matched - it skips to BUILD-END
  3. Because BUILD-LASTEXIT is still set to "FAIL" it exits without printing anything.
BUILD-END() {
	# Fail command.
	if [ "${BUILD_LASTEXIT}" = "FAIL" ]; then
		return 0;
	fi
...

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.