GithubHelp home page GithubHelp logo

pipex's Introduction

💈 pipex

Content

Summary

Description

Error management

Tester

Disclaimer

Summary

This project will let you discover in detail a UNIX mechanism that you already know by using it in your program.

The main goal is to mimic behavior of the bash command pipe [|]

Description

Your program will be executed as follows:

./pipex file1 cmd1 cmd2 file2

It must take 4 arguments:

file1 and file2 are file names.

cmd1 and cmd2 are shell commands with their parameters.

It must behave exactly the same as the shell command below:

$> <code file1 cmd1 | cmd2 > file2

Example

./pipex infile "ls -l" "wc -l" outfile

< infile ls -l | wc -l > outfile

< - is used to redirect output

> - is used to redirect input

./pipex - program

infile - file to read text from

“ls -l” - first command that will process text from infile

“wc -l” - second command that will process output from first command

outfile - file to write the result of the second command

Error management

Errors I tried to pay attention on:

• check leaks using valgrind

valgrind --track-origins=yes --trace-children=yes --leak-check=full ./pipex [args]

• outfile is empty

• infile is empty

If infile is empty and second command wc0

• command is written with path

./pipex infile "///////usr/bin/grep hello" "wc -l" file2

• command is not a directory

• program exit codes

echo &?

• Error file openning

    ◦ if first file doesn't exist

    ◦ if first file doesn't have rights on read

• Commands errors

    ◦ Empty command

./pipex infile "" "     " outfile

    ◦ First comand not found

./pipex infile "cats" "wc -l" outfile

    ◦ Second command not found

./pipex infile "cat" "what" outfile

    ◦ Both commands not found

./pipex infile "cats" "meow" outfile

• All errors at once

./pipex nofile "ca" " " /dev/null/; echo $?

Tester

I made a simple tester for pipex project called test_pipex.sh

It tests only mandatory part.

How it works

It compares using diff outputs from pipex program and from bash command pipe | by creating output files. Also it checks exit codes of pipex program and of bash command also sending it to output files (using echo $?) and comparing with diff.

How to run

In directory with pipex program run:

bash test_pipex.sh

Outputs

You can see outputs of your program in tests/check_outs/file_shell and of bash command pipe | in tests/check_outs/file_pipex files.

Disclaimer

This tester is not highly professional or super complicated bash script code. It is just a number of different arguments for pipex program comparing with bash command pipe |.

You can use it to check outputs of your program but not as an absolute reference for defence or for making your code relevant.

Moreover I used this only on Mac OS.

I am sure there are a lot of things to modify and to improve in this tester. I am open to new ideas 💡

pipex's People

Contributors

d-daria avatar

Stargazers

 avatar  avatar

Watchers

 avatar

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.