Skip to content

add a way to read from stdin in combination with other input_files args#622

Closed
rubensayshi wants to merge 1 commit intoargotorg:developfrom
rubensayshi:usestdin
Closed

add a way to read from stdin in combination with other input_files args#622
rubensayshi wants to merge 1 commit intoargotorg:developfrom
rubensayshi:usestdin

Conversation

@rubensayshi
Copy link

@rubensayshi rubensayshi commented Jun 2, 2016

until now it was only possible to either use stdin or a list of paths, with - you can combine the 2.

when you specify -:

  • it will add cwd to allowed directories (so you can import from cwd)
  • you can add other arguments and still be reading from stdin too, eg; myimports/=~/mysolimportsdir
echo '
contract mul2 {
    function double(uint v) returns (uint) {
        return v * 2;
    }
}
' > mul2.sol;

echo '
import "mul2.sol";

contract testme {
    function main() returns (uint) {
        mul2 x = new mul2();
        return x.double(5);
    }
}
' > testme.sol

# ./solidity/build/solc/solc --abi < testme.sol # doesn't work: Source "mul2.sol" not found: File outside of allowed directories.
./solidity/build/solc/solc --abi - < testme.sol # does work

rm mul2.sol
rm testme.sol

@chriseth
Copy link
Contributor

chriseth commented Jun 2, 2016

Hm, usually you use - to mean stdin, would that also work?

@rubensayshi
Copy link
Author

I'm not too familiar with the boost arg parsing stuff, adding allow_long_disguise as style will allow all long options to be used as short options too.
I couldn't find a way to specify this for a single option...

see; http://www.boost.org/doc/libs/1_39_0/doc/html/boost/program_options/command_line_style/style_t.html

@chriseth
Copy link
Contributor

chriseth commented Jun 8, 2016

A quick test revealed that - will just end up in m_args["input-file"]. So please add a check whether the file name is - and if yes, read from stdin. You can even combine that with the part that checks if there is no input file at all.

@rubensayshi
Copy link
Author

rubensayshi commented Jun 9, 2016

ah, sorry I misunderstood, I thought you meant you wanted -stdin!

updated to support - as input file

{
bool usestdin = !m_args.count("input-file");

if (m_args.count("input-file")) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is unnecessary, isn't it?

@rubensayshi
Copy link
Author

updated to fix the excidental code style changes!

@chriseth
Copy link
Contributor

Looks good, but please rebase, it cannot be merged like this.

@rubensayshi
Copy link
Author

rebased

@rubensayshi
Copy link
Author

not entirely sure what happened (debugging atm) but it seems to conflict somehow with https://github.com/ethereum/solidity/pull/652/files

so don't merge ;)

@rubensayshi rubensayshi force-pushed the usestdin branch 2 times, most recently from 41bed67 to 40f0002 Compare June 20, 2016 13:57
@rubensayshi
Copy link
Author

@chriseth rebased and redid it (again), figured I had to filter out the - from the input files ...

it might be nice to have tests for the CommandLineInterface... but that would require decoupling it from cin / cerr / cout by passing those into the constructor as std::istream& I guess (I'm just getting started with cpp)? shall I?

shall I do that as a seperate PR and you can merge that before this one so I can add tests to this one after that is merged?

@rubensayshi rubensayshi changed the title add --stdin option to read from stdin when paths are also given. add a way to read from stdin in combination with other input_files args Jun 23, 2016
@rubensayshi
Copy link
Author

rubensayshi commented Jun 23, 2016

updated so that when you - it will add cwd to allowed dirs, because if you'd do =pwd`` combined with --add-std it would otherwise break.

for (unsigned idx = 0; idx < inputFiles.size(); ++idx) {
string path = inputFiles[idx];
if (path == "-") {
inputFiles.erase(inputFiles.begin() + idx);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it would be better to loop through m_args["input-fil"].as<vector<string>>() and add everything to inputFiles that is not "-".

Also the current routine does not work correctly if you specify - twice.

@chriseth
Copy link
Contributor

Closing in favour of #912

axic pushed a commit that referenced this pull request Nov 20, 2018
It should be a "|" instead of "[".
axic pushed a commit to ipsilon/solidity that referenced this pull request Apr 22, 2025
* ✨ Receiver (argotorg#622)

* ⚡📬 callback fallback

* 🤏 scrunch

🤏 scrunch comments a bit

* 👌 Fallback function triggered when upper 224 bits of 0x40 are mostly zero.

👌 Fallback function triggered when upper 224 bits of 0x40 are mostly zero.


* ⚡ optimize / formatting

⚡ optimize / formatting

* ✍️ Write some tests n stuff

* ⚡ zimplify codesize

* 🥢 prefer less gas

* 🥢  nit that dbl comment

🥢  nit that dbl comment

* 🥌 Simpler and future-proofed is also cheaper ofc

* 👌 Back to known magic vals.

* 📁 File into accounts

* 📍 Doc acct contracts in README

* 🤏 header

🤏 header


* 🤏 header

🤏 header


* 🪡 Stitch in comment on fallback pass cond

* ✨ EIP4337 Simple Account (argotorg#623)

* 🪄 EIP4337 Base Account

* 📁 Make and refile into `accounts`

* ⚡ Pinion owned clone base & optimize & typo nits

* 🥌 Simplify and support contract signing owner

* Tidy

* Update README

* Tidy

* Optimize

* Add tests

* Tidy

* Optimize

* Tidy

* Add comment

* Add deposit functions

* Fix

* Tidy

* Use gas() instead of not(0)

* Edit comments

* Fix comments delegatecall -> call

* Use SignatureCheckerLib to validate signature

* Add signature check tests

* Edit tests

* ✏️ Txt nits

* Add delegateExecute

* Add delegateExecute test

* Tidy

* 🏧 As in Ownable, onlyOwner functions are payable

* Make initialize payable

* Edit comments

* Edit comments

* Futureproof

* Strengthen tests

* Change to use Execution struct

* Execution -> Call

* Optimize

* Optimize and strengthen tests

* ✨ ERC4337: 1️⃣2️⃣7️⃣1️⃣ (argotorg#642)

* 1️⃣2️⃣7️⃣1️⃣

* 🤌 Pull branch

* ✔️ EOA case (1o1)

use hybrid validation method

* ✔️ EOA case test

* 📸 snapshot

* Optimize

* Edit comments

* Add comment

* Optimize

* Copypasta toEthSignedMessageHash to SignatureCheckerLib

* Add delegateGuard

* Add comment

* Tidy

* Add missing restore part of free memory pointer

* 🥢 Typo nit

Remove extra `be` in comment and also use `so` as coordinating conjunction removing `that`. So it's not a subordinating conjunction.

* 🤏 fmt

🤏 arrange imports (libzip is w/n receiver so can come next and ++ aesthetics) and remove re-explanatory comment.

* ✨ ERC4337Factory (argotorg#644)

* Add ERC4337Factory

* Update README

* Edit comment

* 🤏 Nits

Nit comment and payable constructor (why not it's a factory right)

* fix offset in _call()

* removed funcs & add tests

* ✂️ Remove unused internal func

`_call` no longer used

* checkStartsWithCaller -> checkStartsWith

* Simplify tests

---------

Co-authored-by: ross <92001561+z0r0z@users.noreply.github.com>
Co-authored-by: atarpara <akpatel0618@gmail.com>
Co-authored-by: 0xlgtm <simon.tan.yu.jing@gmail.com>

* delegateGuard -> storageGuard

* Tidy test

* ✨ ERC4337 direct storage (argotorg#645)

* Add test

* ~ snap

* assert optimizes & goes harder in storguard

* mock EP receive() to match StakeManager.sol

* ⚡ optimize deposit via EP receive()

* ⚡ optimize balance getter w/ STL fmt

* 🤏 assert -> require

* Add comments and extcodesize check on addDeposit

* Tidy

* Move back extcodesize check to deposit functions, make entryPoint view

* Snapshot

---------

Co-authored-by: ross <92001561+z0r0z@users.noreply.github.com>
Co-authored-by: atarpara <akpatel0618@gmail.com>
Co-authored-by: 0xlgtm <simon.tan.yu.jing@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants

Comments